4 ms·
I want to read some good C code. Can anyone recommend me a project that's not too big? I'm thinking of skimming some of these core linux libraries [0] [0] http
by thepete2 7y ago
I want to read some good C code. Can anyone recommend me a project that's not too big? I'm thinking of skimming some of these core linux libraries [0]
[0] http://linuxfromscratch.org/lfs/view/stable-systemd/chapter03/packages.html http://linuxfromscratch.org/lfs/view/stable-systemd/chapter0...
- lcall 7y agoLate to this, & am not really a C programmer (longtime bash & java/scala etc, and studying Rust now), but for exemplary C I think of OpenBSD core utilities first (ie, not ports & packages), given their ongoing auditing for security and correctness. The code can be browsed online, or installed as part of a basic system. I found it interesting to browse starting with some smaller utilities like echo and ls. Resources: https://cvsweb.openbsd.org/src/bin/ https://cvsweb.openbsd.org/src/bin/ https://cvsweb.openbsd.org/ https://cvsweb.openbsd.org/ https://github.com/openbsd https://github.com/openbsd https://www.openbsd.org/anoncvs.html https://www.openbsd.org/anoncvs.html https://www.openbsd.org/ https://www.openbsd.org/ (where I got the above links, on the left side under "Getting Source")
- lcall 7y ago(just to improve my previous accuracy where I mentioned scala & rust, though it's too late to edit: ...and C++ and many other things .)
- dana321 7y agolmdb is one that comes off the top of my head. But even that the main file is 11000+ lines of code.
- rgrau 7y agoredis is very good. Also, any suckless project is very readable. I liked Lua code too. I'm not a C programmer but these projects have this Quality in common that transcends the programming language (I think). Opinions?
- porknubbins 7y agoIf you’re going to try read along with Robert Love’s Linux Kernel Development. Even outdated its the best guide I’ve found. That said I’m kind of a C beginner so take with a grain of salt. I frequently get derailed by the Macros, architectural stuff etc in the kernel and can’t figure out what exactly the code is doing.
- userbinator 7y agoThe FreeBSD core utilities are reasonably short: https://github.com/freebsd/freebsd/tree/master/bin https://github.com/freebsd/freebsd/tree/master/bin
- devnonymous 7y agoYou might want to read '500 lines or less'[1]. Here you not only read the code but also see it in the context of the 'bigger picture' of the design / architecture / problem being solved. [1] https://www.aosabook.org/en/index.html https://www.aosabook.org/en/index.html