3 ms·
It doesn't just buy safety. It also makes it possible to include null bytes inside of strings.
by bobbyi_settv 6y ago
It doesn't just buy safety. It also makes it possible to include null bytes inside of strings.
- NavinF 6y agoand with length+array you don't need 2 copies of so many functions (array input vs string input) No matter how you slice it, null termination was a mistake.
- kortex 6y agoThis is the part that boggles my mind. It's not like fat pointers just didn't exist at the time. You need fat pointers any time you do anything with dynamic non-string binary data. Null is always 1 byte minimum so at best you save size_t-1 bytes per string. Ignoring clever structures like LEB128 varint length. This is a classic case of "simple is actually complex". How many billions of dollars has null terminal strings cost? Hope that 3 bytes of overhead per string saved is worth it.