Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To be fair, agreement is not universal that null-byte termination is a good thing. Though that doesn't detract a thing from the man's greatness.


C strings have certainly proved more useful than contemporary attempts like Pascal strings. Those used an integer prefix to store the length of the string, but because any language at the time was expected to provide reasonable performance on prevalent 8-bit machines, the Pascal string length field was only 8 bits. Hence strings were limited to 255 characters.

The null terminator is actually an elegant machine-independent solution to this problem.


The NUL terminator is an extraordinary hack, in the best sense of that word, but it is not elegant. Strings that have to be expensively interrogated to discover their length have cost the industry billions and billions of dollars due to the inevitable software faults they cause.


Yes, I would say it is the single worst idea to come out of C.


I suspect that null-terminated byte strings are important in some non-trivial, non-obvious way.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: