Linked by Eugenia Loli on Mon 10th Oct 2005 16:48 UTC, submitted by Shlomi Fish
General Development Shlomi Fish has written a new essay titled "When C is the Best? (Tool for the Job)". Its theme is giving several reasons (besides high speed and low memory consumption) why some code should still be written in C.
Thread beginning with comment 42680
To read all comments associated with this story, please click here.
Re: Bleh
by rajj on Mon 10th Oct 2005 18:01 UTC
rajj
Member since:
2005-07-06

That's not a misfeature. In the hardware, strings ARE arrays of chars. A string is an abstraction and C doesn't hide that from you.

Reply Score: 1

RE: Re: Bleh
by on Mon 10th Oct 2005 18:22 in reply to "Re: Bleh"
Member since:

Most modern pascal compilers let you use a string also as an array of chars. While it's true that string is an abstraction, the notion of string exists even on hardware implementations - check scas* opcodes on x86. (And yes, I'm aware those aren't string-specific, on the sense of char array)

Reply Parent Score: 0

Re: Bleh
by stew on Mon 10th Oct 2005 18:50 in reply to "Re: Bleh"
stew Member since:
2005-07-06

The lack of abstraction is C's problem. You are being tricked into thinking your program is portable when it isn't. Just because you can compile your C program on any platform doesn't mean it'll do the same on every platform:
C doesn't abstract endianess. It doesn't abstract a platform's native memory alignment or pointer size. Strings as null-terminated byte arrays don't work with 16bit Unicode (which you should expect that one or the other function on a target platform may actually return - like a file name).

Reply Parent Score: 1