What does good, modern c code look like?

I consider Steve Dekorte's IO language implementation to be a good example for clean and pragmatic modern-day C.


Check out git source code: http://github.com/git/git/tree/master


This is completely anecdotal, but I've heard that the SQLite project is considered good code.


Dave Hanson's C Interfaces and Implementations is a very well-crafted library of about 7000 lines of code. The book is great if you can afford it.

The implementation of the Lua programming language and libraries is about 17,000 lines of C code and is very well done but quite sophisticated in places—compilers and garbage collectors are not so easy to understand without background in those fields. But the code is beautifully engineered.

Git is over 125,000 lines of code. I can't recommend that anyone study it as an example of how to engineer C code. Just the design and public interfaces, let alone the implementations, are hard to understand—which is why there are so many git tutorials.

Tags:

C