3 ms·
I find the C backlash to the excesses of C++ fascinating. On the flip side, I wonder how people deal with 'programming in the large' with C - other than 'just
by ryanobjc 13y ago
I find the C backlash to the excesses of C++ fascinating.
On the flip side, I wonder how people deal with 'programming in the large' with C - other than 'just be really really careful'
- ninjin 13y ago> I find the C backlash to the excesses of C++ fascinating. I whole-heartedly agree. Something that blew my mind back in undergraduate school was tree.h by Niels Provos, [1] which is a complete key/value-type agnostic Red-black Tree [2] in a single header file. Just recently when re-learning C I stumbled upon klib [3] which has a similar take on generic programming by "abusing" the preprocessor. If I am allowed to side-track, I found "C The Hard Way" to be a good resource when re-learning C. I also had a lot of fun with "Expert C Programming", although it is a bit dated. I highly recommend it once you have a grasp of the language basics. I have heard good things about "21st Century C", but I am still wondering what other good resources there are out there. [1]: http://svnweb.freebsd.org/base/head/sys/sys/tree.h?view=markup http://svnweb.freebsd.org/base/head/sys/sys/tree.h?view=mark... [2]: http://en.wikipedia.org/wiki/Red%E2%80%93black_tree http://en.wikipedia.org/wiki/Red%E2%80%93black_tree [3]: https://github.com/attractivechaos/klib https://github.com/attractivechaos/klib
- noselasd 13y agoYou don't always need preprocessor tricks to generate a special purpose red-black tree, you can use an intrusive variant like this: http://cgit.osmocom.org/libosmocore/tree/include/osmocom/core/linuxrbtree.h http://cgit.osmocom.org/libosmocore/tree/include/osmocom/cor.... This works together with the container_of macro: http://stackoverflow.com/questions/15832301/understanding-container-of-macro-in-linux-kernel http://stackoverflow.com/questions/15832301/understanding-co... In similar spirit, the linked list variant: http://cgit.osmocom.org/libosmocore/tree/include/osmocom/core/linuxlist.h http://cgit.osmocom.org/libosmocore/tree/include/osmocom/cor..., though the macros in sys/queue.h are also useful for linked lists.
- deleted 13y ago[deleted]