3 ms·
A much better C standard library would help a lot into thinking at C code from an higher level point of view. Especially if you have easy to use data structures
by antirez 16y ago
A much better C standard library would help a lot into thinking at C code from an higher level point of view. Especially if you have easy to use data structures in form of a lib, it is really easy to resist to use a list and O(N) lookups just to type less code where an hash table is a better feet.
Why the C standard library does not get improved with a few data types like linked lists, hash tables, dynamic strings, and so forth is something I can't understand (one common reason why poorly written C code ends slower than equivalent code wrote in a scripting language is because of strlen() and other stupid string operations into a loop ending into exponential time complexity).
- JoachimSchipper 16y agoResistance from embedded programmers, I gather. Don't forget that C crosses a huge number of platforms. That said, BSD sys/tree.h (self-balancing trees) and sys/queue.h (linked lists of all kinds) give you a lot of functionality and can easily be made part of your project (be warned, though: glibc has a very incomplete implementation, so make sure to use the BSD version.)
- pavlov 16y agoThere have been attempts to provide a better standard library in plain C, and in fact these are fairly well available in operating systems. The problem is that no library spans all platforms. On Unix systems with Gnome, there's GLib. It's very well-featured, very portable and available as prebuilt DLLs for Windows, at least. On Mac OS X and iOS, there's CoreFoundation. My humble opinion is that it's the best OO-style C library. I'd love to use it on Windows, but unfortunately Apple wavered on their original commitment of open-sourcing CoreFoundation. They stopped releasing the source, and getting CF to build became very complicated at some point. I've lost track of what's the current situation, but clearly this makes it very difficult to rely on CF for cross-platform applications.