Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Good C (not C++) code for reading/learning?
7 points by jgalvez on Oct 11, 2008 | hide | past | favorite | 9 comments
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?


The 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/

There's a suggested roadmap for reading it, too: 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.


SQLite 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.


Interesting


This 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.


GNOME code and the Linux kernel are both pretty good examples - writing a well-structured, small GTK+ app will do wonders for your C skills


How about the Linux Kernel? - Well-documented. - Always good to know. - Good, well-organised code. - Real-life C code.


It's a little dated now but the Tcl/Tk source is very good. I'd also recommend the FreeBSD source tree.


One piece of code I found particularly useful was the old tftp. It's small enough yet very instructive.


Git?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: