3 ms·
Slightly related is C language using null terminated strings which is the source of buffer overflows. From what I remember the assembly languages of whatever pl
by hashar 3y ago
Slightly related is C language using null terminated strings which is the source of buffer overflows. From what I remember the assembly languages of whatever platform they were using relied on NUL, an alternative was to use a leading single byte to set the length of the string, so "hello_world" which is 11 bytes would be:
0x0A h e l l o _ w o r l d
But that limited the length of strings to 255 characters and using two bytes rather than one would add memory pressure. Dennis Ritchie then went with null terminated strings which has the advantage of allowing any size of strings and is consistent with the assembly they were used with. The drawbacks is decades of buffer overflows :)
Eventually I found an abstract on https://en.wikipedia.org/wiki/Null-terminated_string#History https://en.wikipedia.org/wiki/Null-terminated_string#History and there is a 2011 paper about it: Communications of the ACM - Volume 54 - Issue 901 - September 2011 - pp 42–44 - https://doi.org/10.1145/1995376.1995391 https://doi.org/10.1145/1995376.1995391 . Direct link to the PDF https://dl.acm.org/doi/pdf/10.1145/1995376.1995391 https://dl.acm.org/doi/pdf/10.1145/1995376.1995391
- pjmlp 3y agoSafer systems programming languages relied on character arrays for lengths greather than 255, as a kind of good enough compromise, since most use cases could fit in 255, and with the help of string libraries it wasn't much of a pain to deal with character arrays instead of strings. Eventually fat pointers were used instead. Which even Denis himself proposed for WG14 during the C89 standardization, and wasn't accepted. https://www.bell-labs.com/usr/dmr/www/vararray.pdf https://www.bell-labs.com/usr/dmr/www/vararray.pdf