← Back to context

Comment by thayne

1 day ago

We should move away from it in C usage as well.

Ideally, the standard would include a type that packages a string with its length, and had functions that used that type and/or took the length as an argument. But even without that it is possible avoid using null terminated strings in a lot of places.

The standard C library can’t even manipulate NUL terminated strings for common use cases…

Simple things aren’t simple - want to append a formatted string to an existing buffer? Good luck! Now do it with UTF-8!

I truly feel the standard library design did more disservice to C than the language definition itself.

  • The standard library hasn't done a damn thing to hurt C. There are better alternatives available and have been for decades. If some noob hasn't figured out that strcpy() is long outdated, that's his personal problem. If some company wants to put clueless noobs or idiots in charge of writing security critical software, that's theirs and their customers' problem, not mine.