3 ms·
> On the other hand, his recommendation to always know string lengths and use memcpy didn't really become common practice over the last 20+ years either, so I'm
by eru 3y ago
> On the other hand, his recommendation to always know string lengths and use memcpy didn't really become common practice over the last 20+ years either, so I'm not sure it was worth all the arguing.
It hasn't become common practice in C. But other languages (like JavaScript or Python) have become hugely popular, and don't use null-terminated strings.
- tomjakubowski 3y agoEven languages in C's niche encode strings as pointer + length, like Rust.
- bonzini 3y agoIt has in the sense that people allocate strings much more than using fixed-size, stack-allocated arrays. Modern C uses things like glib's GString, which (in addition to keeping the NUL terminator) track the length and can resize the underlying memory. And people also use a lot more asprintf instead of strcpy and strcat.
- jacquesm 3y ago> On the other hand, his recommendation to always know string lengths and use memcpy didn't really become common practice over the last 20+ years either It was the way plenty of languages from the 70s stored their strings, including such popular ones as BASIC.