Fog Creek Software
Discussion Board

Code reading

I would like to read efficient, robust, clean code.

Can anyone recommend me some widely available source code to look at ?

Maybe a compiler or an OS ?

Something which is full of wonderfull tricks and where I can learn some stuffs from

Sunday, April 27, 2003



Or for something smaller,


Sunday, April 27, 2003

The Linux kernel source code should qualify :)

Monday, April 28, 2003

Knuth, "TeX: The Program" and "METAFONT: The
Program". They are certainly efficient and robust
code. They're better documented than almost any
other code you're ever likely to read. And they're
close to bug-free.

On the other hand, they're written in Pascal, in a
rather old-fashioned style. And they're designed
for old slow machines with not much memory. That's
one reason *why* they're unusually efficient code,
but some of the tradeoffs Knuth makes wouldn't
seem so reasonable these days.

If you're only going to look at one of those, make it
METAFONT, because (1) there are more cool
algorithms there and (2) what METAFONT is doing
is probably more interesting to most people than
what TeX is doing. (For the most part.)

The gzip source code is unusually well commented,
and does some interesting things.

You could look at bigger things like Linux, FreeBSD,
gcc, and so on. Be warned that you'll need to put in
quite a lot of work to understand what's going on
with a large system.

Gareth McCaughan
Monday, April 28, 2003

the linux kernel source code is not clean and easy to read. look at openbsd's pf's clean.

Monday, April 28, 2003


>the linux kernel source code is not clean and easy to read.

Compared to alot of old commercial C code I've seen it is,
but whatever...

Tuesday, April 29, 2003

*  Recent Topics

*  Fog Creek Home