Ask HN: What source code is worth studying?
I realized recently that it's been a long time since I looked at anyone else's code outside of the context of debugging or working on it for hire. In your opinion, what are some examples of particularly well-designed or implemented software projects worth looking at to broaden one's own horizons as a programmer?
116 comments
[ 4.3 ms ] story [ 203 ms ] threadThis is also good, Standard Function Library:
http://legacy.imatix.com/html/sfl/
The book by David Hanson is the literate program.
That's what I was trying to determine.
http://www.sqlite.org/testing.html
I've found that doing so a) improves my knowledge of what's going on under the hood tremendously, and b) has taught me a fair bit about how to do code reviews and make difficult design decisions. Studying the kernel itself line-by-line would take ages, but reading a few threads a week depending on what piques my interest is totally manageable.
And the LLVM compiler is far more understandable than gcc sources: http://llvm.org/viewvc/llvm-project/llvm/
Is Minix 3 still readable, or do you recommend Minix 2?
By contrast Perl makes very heavy use of macros for portability, to an extent that may induce brain lock in many people, and makes your debugger very hard to follow. This is not to say that its use of macros is a bad thing in the end, but it is a definite shock.
Check out the regex compilation module: http://cpansearch.perl.org/src/GBARR/perl5.005_03/regcomp.c
And execution: http://cpansearch.perl.org/src/GBARR/perl5.005_03/regexec.c
Similar previous discussions:
http://news.ycombinator.com/item?id=225577
http://www.reddit.com/r/programming/comments/26dyh/ask_reddi...
http://www.texmacs.org/tmweb/download/sources.en.html
http://www.spinellis.gr/codereading/
(disclaimer: I'm one of developers)
http://bit.ly/131cxL (.doc file)
those help. if you can figure out the source code without the documentation at the agg site + those files, more power to you. but basically you are nuts.
Joe tends to do things his own way, which works out fine, but does tend to depart from most people's Cocoa/Touch code.
http://tomayko.com/writings/unicorn-is-unix
I found Sinatra to be an interesting read (and specifically how it parses the app configuration into methods):
http://github.com/sinatra/sinatra
For idiomatic Ruby and Rails stuff I have probably learned more from Rick Olson's stuff (http://github.com/technoweenie/) than any other single source. Sometimes I think he tends to be too clever for his own good, but the code is good to read for that reason even if simpler things are better in production.
From a graphics and game engine perspective, it was very informative to go through pieces of of the source - I was mainly interested in the client/server and collision detection areas of the code.
The Lua VM's source (http://www.lua.org/source/5.1/)
It feels well organized almost throughout, and it's a joy to experience the clarity of thought that went into it. In fact, most of djb's code has a similar feeling to it.
Arthur Whitney's code: http://www.nsl.com/papers/origins.htm
Being able to read this (and not merely decode it, but read it, in a manner similar to how you would read a book) will broaden your horizons like nothing else I've seen.
That's also where I saw calloc.c - A portable implementation of calloc. I distinctly remember it being one of the cleverest hacks I've seen.