News for hackers. Stuff that matters.

Ask HN: Examples of beautiful C code?

Hey, HN,

I hardly ever read other people's code, but I'd like to start dedicating a few hours each week to studying idiomatic C. The ultimate goal is to improve my own code.

What are some codebases that are worth studying? Bonus points for open-source projects that are looking for new contributors.

( 9 comments | 17 points | on HN )
Re:Ask HN: Examples of beautiful C code? by apaprocki on Friday November 11, 2011 @12:35PM (#3225378)
Since it was just posted, the xv6 ANSI C Unix source is nice and fairly compact. They even provide a nice PDF for you to take it with you:

http://pdos.csail.mit.edu/6.828/2011/xv6/xv6-rev6.pdf

Also the low-level GLib core library is good:

http://git.gnome.org/browse/glib/tree/glib

Re:Ask HN: Examples of beautiful C code? by herbivore on Friday November 11, 2011 @12:59PM (#3225460)
You should check out Redis - https://github.com/antirez/redis
Re:Ask HN: Examples of beautiful C code? by tjholowaychuk on Friday November 18, 2011 @08:38PM (#3254298)
I'm certainly not the best C programmer out there but hey, might want to have a look at:

- https://github.com/visionmedia/luna - https://github.com/visionmedia/libcss

Re:Ask HN: Examples of beautiful C code? by deutronium on Friday November 11, 2011 @01:15PM (#3225514)
You might be interested in http://www.amazon.com/Beautiful-Code-Leading-Programmers-Pra...

I believe one of the examples they gave in C was the diff algorithm from Subversion.

Re:Ask HN: Examples of beautiful C code? by infamouscow on Saturday November 12, 2011 @02:48AM (#3227392)
The Quake 3 source code - https://github.com/xxpor/Quake
Re:Ask HN: Examples of beautiful C code? by slig on Saturday November 12, 2011 @05:12AM (#3227547)
* SQLite
Re:Ask HN: Examples of beautiful C code? by ivysummer on Saturday November 12, 2011 @07:10PM (#3229340)
linux kernel code is good enough for c examples.
Re:Ask HN: Examples of beautiful C code? by davyjones on Friday November 11, 2011 @11:10PM (#3227098)
* Postgresql

* Varnish

Re:Ask HN: Examples of beautiful C code? by naner on Friday November 11, 2011 @05:02PM (#3226302)
the netbsd kernel.