← Back to context

Comment by imtringued

2 years ago

Nothing prevents those operating systems from offering custom string types.

In reality, a ton of stuff does. As an example: What do you do if someone calls your new string+length API with an embedded \0 character? Your internal functions are all still written in C and using char* so they will silently truncate the string. So you need to check and reject that. Except you forgot there are also APIs (like the extended attrs APIs) that do accept embedded \0. The exceptions are all over the place, in ioctl calls passed to weird device drivers etc.

  • Windows internally uses string+length struct, null terminated string API is just compatibility interface on top of it.

*new operating systems

You can't change the string type without breaking all apps and services.

  • Even on a new OS it's going to be a compatibility problem. Implementing even partial POSIX compatibility makes porting stuff easier, but changing how stings work is going to make it significantly harder.