Hacker News new | past | comments | ask | show | jobs | submit login

Those advocating for length+pointer should really write it up, including showing all the time and memory complexity for all operations and pointing out its cons as well.

There are numerous safe-string libraries for C. I don't think anyone uses them much.

To me, null-terminated strings look like admirable restraint from Thompson, Kernighan and Ritchie.




What are the pros of null-terminated strings? You have to recalculate something you already know at each string operation, potentially failing. It is slow and unsafe.

Languages where a string type is possible to have usually make use of length and non-null-terminated, while I think C++ does length and C-string with longer texts but for short string can “hack” the text itself into the pointer.




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

Search: