News for hackers. Stuff that matters.
Re:Did Ken, Ritchie and Brian choose wrong with NUL-terminat... by tbirdz on Tuesday January 16, 2018 @01:28PM (#16160644)
1 additional byte of overhead would give you 2 bytes for the length, since you wouldn't have to have the NUL byte at the end of the string.

You could do some kind of variable int encoding scheme, where longer strings would require more bytes for length, with some overhead to indicate how many length bytes are required for each string.

Re:Did Ken, Ritchie and Brian choose wrong with NUL-terminat... by jandrese on Tuesday January 16, 2018 @02:22PM (#16161332)
You don't even need that length prefix if you use something like SDNV. Ironically this would have introduced a case where you have something like a null terminator that can overflow.

It would have also been a fair bit of overhead on those old single-Mhz machines. Still, almost everything you do with strings is slow so it probably would have been manageable. As an added bonus, it is zero space overhead for short strings (up to 127 characters) which are the majority of strings.

Re:Did Ken, Ritchie and Brian choose wrong with NUL-terminat... by jerf on Tuesday January 16, 2018 @02:06PM (#16161133)
In the PDP era, they would have noticed the overhead of having a variable-length int at the beginning they would have to decode.

In the modern era, it's probably cheap to the point of being free, because in the vast majority of cases I would expect branch prediction to largely eliminate the checks as being very predictable.

Re:Did Ken, Ritchie and Brian choose wrong with NUL-terminat... by pjmlp on Tuesday January 16, 2018 @05:24PM (#16163300)
Even in the PDP era I am not so sure, given the architectures and OSes being developed outside AT&T, some of them in production.
Re:Did Ken, Ritchie and Brian choose wrong with NUL-terminat... by PopsiclePete on Tuesday January 16, 2018 @02:12PM (#16161220)
So then....they chose correctly?
Re:Did Ken, Ritchie and Brian choose wrong with NUL-terminat... by jerf on Tuesday January 16, 2018 @04:10PM (#16162638)
Despite being vigorously opposed to NUL-termination in the modern era, yes, I would not criticize the people who actually made the decision for the PDP. They had no real reason to believe we'd still be discussing that decision 60 years later.