3 ms·
It's a classic case of moving the complexity from one part of the system to another. "Strings are just character arrays" seems simple and elegant, but in realit
by jdlshore 6y ago
It's a classic case of moving the complexity from one part of the system to another. "Strings are just character arrays" seems simple and elegant, but in reality is a giant mess, because strings are not just character arrays, any more than dates are just an offset from an epoch.
Human concepts are inherently messy. "Elegant" solutions just shove the mess down the road.
- lultimouomo 6y agoOn the contrary, I think "Strings are just character arrays are just pointers" is the solution, not the problem. As with non-character arrays, you must always pair the pointer with a length. (I don't like the idea of prefixing the length because it prevents su stringing). The problem is the null termination, which is not general to arrays (though it is sometimes used with arrays of pointers).
- ByteJockey 6y agoYou sometimes see sentinel values used with varargs (only if they're all the same type), which is basically just an array with more boilerplate. That being said. Length as a first parameter and the rest of the arguments being the variadic bit is also quite normal.
- konjin 6y agoYou're just moving the complexity from strings into unsigned integers. Your strings are limited by the size of whatever you put in the head of the string. Sure 16 exabytes sounds like a lot today, but so did 4 billion ip addresses. Differently bad is not better.
- jdlshore 6y agoI didn’t say anything about unsigned integers, or any specific approach to encoding strings at all, so I’m not sure what you’re trying to say here.