3 ms·
Ask HN: Good C (not C++) code for reading/learning?
I'd like to polish up my C. Can you recommend some good open source projects which are good examples of coding style and organization in C?
- silentbicycle 18y agoThe source for Lua is pretty good (if a little dense at times), and you can read it in-browser: http://www.lua.org/source/5.1/ http://www.lua.org/source/5.1/ There's a suggested roadmap for reading it, too: http://www.reddit.com/comments/63hth/ask_reddit_which_oss_codebases_out_there_are_so/c02pxbp http://www.reddit.com/comments/63hth/ask_reddit_which_oss_co... It is written in ruthlessly standard ANSI C (for maximum portability). It will probably also complement your C -- it's intended to be a handy drop-in scripting language to embed in C programs, though it's also a pretty cool language on its own merits. They had an unwavering focus on keeping it clean and very small for embedding, and they make some really interesting choices along the way. It's sort of like a minimalistic Python; it gets a lot of power out of using "tables" (rather like Python dictionaries or Perl hashes) as a primary data type.
- SwellJoe 18y agoSQLite is always recommended in threads like this (of which, I will point out, there have been several here and at reddit...you might like to search for them). I haven't looked at it since very early releases, but I'm guessing quality has gotten better over time, since it is more stable than ever and faster than ever, and still astoundingly lightweight.
- yourabi 18y agoInteresting
- rmk 18y agoHow about the Linux Kernel? - Well-documented. - Always good to know. - Good, well-organised code. - Real-life C code.
- RobGR 18y agoThis is probably more than you are looking for, but the fftw code ( www.fftw.org ) is a pretty amazingly designed piece of C code that does some very advanced stuff. However, if you trying to get off to a good start, you might want simplistic examples. One thing I think helps you become a better programmer, is to read your own code carefully a long time after you have written it.
- dchest 18y agoGit?
- bayareaguy 18y agoIt's a little dated now but the Tcl/Tk source is very good. I'd also recommend the FreeBSD source tree.
- xpaulbettsx 18y agoGNOME code and the Linux kernel are both pretty good examples - writing a well-structured, small GTK+ app will do wonders for your C skills
- reginaldo 18y agoOne piece of code I found particularly useful was the old tftp. It's small enough yet very instructive.