4 ms·
It’s very easy to write a string library in C which makes string operations high level (both in API and memory management). Sure, you shouldn’t HAVE to do this.
by dboon 11mo ago
It’s very easy to write a string library in C which makes string operations high level (both in API and memory management). Sure, you shouldn’t HAVE to do this. I get it. But anyone writing a parser is definitely skilled enough to maintain a couple hundred lines of code for a linear allocator and a pointer plus length string. And to be frank, doing things like “string operations but cheaply allocated” is something you have to do ANYWAY if you’re writing e.g. a parser.
This holds for many things in C
- criddell 11mo ago> a pointer plus length What would length represent? Bytes? Code points? Anyway, I think what you are asking for already exists in the excellent ICU library. And it's not a very easy thing to maintain. Unicode stuff changes more often than you might think and it can be political.
- steveklabnik 11mo agoThis is just a variation of the "skill issue" argument. If it were correct, we wouldn't see these issues continue to pop up. But we do.
- josefx 11mo agoI think it is more a matter of convenience. There are countless string implementations for C, some tiny projects, others part of larger frameworks like Glib. At the end of the day a C developer has to decide if they are going to pull in half of gnome to handle a few lines of IO or if they are just going to use the functions the C standard conveniently ships with. Most people are going to do the later.