5 ms·
How often does C add things like this in general? I want to say... basically never? You're free to roll your own String type that has the length. No clue why p
by staticassertion 8y ago
How often does C add things like this in general? I want to say... basically never?
You're free to roll your own String type that has the length. No clue why people don't just do that though (I assume many do, but obviously a ton do not).
- blub 8y agoC doesn't really support properly encapsulated user-defined types, so yes, one can create their own String type but it will still be a pain to use and error-prone. One example is the stretchy buffer library that I saw posted recently here.
- TimJYoung 8y ago:-) You're certainly right here, but given that everyone thought that C was "going to be sent to the farm" a while ago and that shows zero signs of being true any time soon, it might be in the best interest of everyone to add such improvements, as long as they don't affect any existing C code. As I stated in my other reply, the only issue that I can see with rolling one's own String type is the handling of the reference counting for implicit deallocation.
- pjmlp 8y agoWe cannot send C to the farm and keep UNIX like OSes around, due to their symbiotic relationship. I really would like that something like SafeC or CheckedC would win the hearts of C devs
- scruple 8y ago> given that everyone thought that C was "going to be sent to the farm" a while ago For certain definitions of "everyone," maybe... I am no longer primarily a C programmer, and haven't been since around the end of 2013, and I'm still firmly in the "C isn't going any where" camp. I just happen to liken this stance to reality.
- TimJYoung 8y agoJust to clarify, I am definitely also not in the camp that thought that C was going away, rather that my general feeling is that most developers are afraid of it because of issues like this, and more sane semantics regarding one of the more widely-used aspects of any language would allow for greater adoption while not sacrificing reliability or backwards-compatibility. IOW, I think it would be a win-win.
- jacquesm 8y ago> No clue why people don't just do that though Most somewhat larger C shops will have their own internal utility library or they'll use one of the more popular batteries included packages which typically takes care of memory allocation, string handling, lists and a bunch of other useful stuff.