Re:Ask HN: What Happened to Borland?
by kaba0 on Friday December 10, 2021 @02:56PM
(#29514732)
How is iterating over the string each time you want to do anything meaningful better? Also, there is a short string optimization, where you can store the string inside the pointer , eg. c++ does just that.
[ Parent
| on HN ]
You didn't read my comment right. My statement is there isn't one true string type. I didn't say you shouldn't use a length field.
Zero terminated strings still make some sense of course - ease of reading when looking at byte level representation, and moderate cost savings in packed structs (4, 8, or 16 byte strings). The former is why I zero terminate by default where possible, even when using a separate length field stored somewhere else (almost always).