4 ms·
something i find more important than how much people use strlcpy, snprintf etc in terms of safety and easy of use of strings in C is the lack of good implementa
by jheriko 13y ago
something i find more important than how much people use strlcpy, snprintf etc in terms of safety and easy of use of strings in C is the lack of good implementation of library functions that give you the string length upfront so you can safely make an allocation of the right size to use such a function with.... coupling that with the fantastic level of brokeness of wchar_t*/wcs functions on the Apple platforms and the poor consistency of the Android NDK (%S, %ls... can't remember) and Microsoft's general lack of respect for the standard and desire to encourage their own brand of 'safe' functions and deprecation I find working with strings in a useful way in C to be an enormous pain when it really shouldn't be.
This should be embarassing when 'script kiddie' languages like Python, Ruby, JavaScript and co. do a fantastically better job. It has nothing to do with the level of abstraction and everything to do with poor implementation of the standard library on /every platform/.
And I am supposed to trust 3rd party libraries when these giants make mistakes with both trivial, yet highly important functionality? It makes me cynical that they want to force me to use their NSStrings, Java string or Platform::String^ crap, which I really don't like to trust because they are bad in their own ways too... how can I trust these people with my strings?
C and C++ are ridiculously cross platform and utilitarian, but this area is definitely one of the weakest imo :/
Still, I don't advocate rolling your own, but making things work safely and nicely across platforms is a pain in the arse
- tedunangst 13y agoWhat makes python strings fantastic and java strings crap?
- jheriko 13y agoi think java strings are pretty fantastic too... its the C string library function implementations which are crap. i don't like introducing any dependency when I shouldn't have to - using Java strings on Android is not something I've yet had to do but I suspect I will if I want good working functionality because the wcs* functions in the C stdlib in the NDK are crap. there are a number of performance and aesthetic reasons for not wanting to use java strings as well but they are largely irrelevant imo...