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

But the question here isn't actually "What is the ONE TRUE STRING format that the language permits, all others to be rigidly banned by the compiler?", the question is "What shall the default string be in the core C APIs and functions?"

If you still need NULL-terminated strings, you could have chosen them, and if you knew enough to so choose, hopefully you know enough to treat them like the dangerous tools they are. Meanwhile, the core C functions and API and UNIX could have been built around the much safer strings, which wouldn't have been all that hard to upgrade to 4 bytes (or more) later. Or we could have done a UTF-8-like size encoding, or turn the default strings into linked lists if they got large, etc. It would be OK, because raw expanses of memory would still be available to you, it just wouldn't be the default.

NULL-terminated strings are the wrong default, even though they should be available to those who really need them.



Multiple string schemes is exactly the sort of fragmentation this industry does not need. Citation: C++.


You mean, basic_string and charstar?


Hm, It can be a real problem if you have the joy of working with old C++ code: the initial codebase might have had its own string type, and then some more classes added by long-gone programmers who thought the earlier types were slow, and then newer code added by people who actually use std::string (well, you get the idea).

(much to my regret, that is a true story.)




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

Search: