I\'m writing a language interpreter in C, and my string type contains a length attribute, like so:
struct String
{
char* charac
Lengths have their problems too.
The length takes extra storage (not such an issue now, but a big factor 30 years ago).
Every time you alter a string you have to update the length, so you get reduced performance across the board.
With a NUL-terminated string you can still use a length or store a pointer to the last character, so if you are doing lots of string manipulations, you can still equal the performance of string-with-length.
NUL-terminated strings are much simpler - The NUL terminator is just a convention used by methods like strcat to determine the end of the string. So you can store them in a regular char array rather than having to use a struct.