The NT kernel is the most beautiful piece of code I've seen. Dave Cutler and team wrote some very, very elegant code that anyone (even if you're not a kernel hacker) can understand. If I need 'code inspiration', I spend some time looking through their code.
Now, the NT kernel itself doesn't have source out there but for folks who are students, you should be able to get your hands on the Windows Researh Kernel (http://www.microsoft.com/resources/sharedsource/windowsacade...). This has all the good stuff (and is much easier to build too)
Modulo Plan9 kernel. It's also lot smaller a read (ca. 50 KLoC and that's it).
NT kernel itself doesn't have source out but for folks who are students
And folks who are hackers should be able to look in certain places to find the leaked version ;>
The overall impression was that it was hacked together in the worst sense of the word. Like there were several teams developing it that did not communicate with each other. Pieces of the kernel are forced together rather than fit snugly by design. I cannot stress enough how mind-boggingly repulsive it was to work with it. And that's not even touching NDIS, the networking module, which can be used for scaring some serious shit out of young programmers.
If you put BSD or Linux code side by side with NT, look me in the eye and tell me that NT kernel is "the most beautiful piece of code you've seen", you will need to see a head doctor.
Having worked on that team and having seen it for myself, it is truly elegant, concise, and very well written. I myself never touched it, and that is for the best. I probably wrote some of the crappy drivers for which you hold so much contempt.
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
http://www.antigrain.com/
The end result is a toolkit which is at a lower level than Quartz 2D et al, but could easily be used to build such an API. It can also be adapted for embedded, or high precision uses.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.
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.
And it's not just their code, everything they do is exemplary. It's one extremely well run software project.
See for example their documentation:
The Lua VM's source (http://www.lua.org/source/5.1/)
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?
This is also good, Standard Function Library:
The book by David Hanson is the literate program.
That's what I was trying to determine.
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.
The best code I've seen: -
Common Lisp - "Paradigms of Artificial Intelligence Programming" by Peter Norvig and "On Lisp" by Paul Graham
C - "C Interfaces and Implementations" and "LCC- a compiler for ANSI C" both by David Hanson. I also found the code for the Player/Stage robotic sim framework surprisingly readable.
I liked the Scala Actors library code as well.
If any HNers know any great codebases in Haskell or Erlang, please post here.
Similar previous discussions:
http://news.ycombinator.com/item?id=225577
http://www.reddit.com/r/programming/comments/26dyh/ask_reddi...
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree...
Joe tends to do things his own way, which works out fine, but does tend to depart from most people's Cocoa/Touch code.
--EDIT---
Found it: http://web.archive.org/web/20050315135351/http://nanocrew.ne...
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):
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.
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.
(disclaimer: I'm one of developers)
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.
http://nedbatchelder.com/code/modules/hyphenate.html
or AI:
[ background : I've used OOP a lot, and thought it was the ultimate, until I discovered lisp... ]
by Douglas Crockford, author of 'JavaScript : the good parts' - http://www.crockford.com/