Live data from Hacker News

Ask HN: What source code is worth studying?

news.ycombinator.com

71–80 of 117 posts

Re: Ask HN: What source code is worth studying?

#71
post #36
post #20

Earlier quoted context omitted.

Minix, not being as 'real world' as the BSD's or Linux, is even more readable, if you're just interested in a quick glance at how an OS works.

From Minix' site: MINIX 1 and 2 were intended as teaching tools; MINIX 3 adds the new goal of being usable as a serious system on resource-limited and embedded computers and for applications requiring high reliability. Is Minix 3 still readable, or do you recommend Minix 2?

Good question. My experience was with Minix 2: I needed a floppy driver to weld on to eCos, and Minix's was by far the easiest to deal with. I haven't looked at Minix 3.

Re: Ask HN: What source code is worth studying?

#72

One way to find code worth reading is to select inspiring developers and look at their code. Most of the developers in "Coders At Work" for example, have Open Source code we can look at learn from. 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…

For haskell I would recommend Xmonad. The code is short, lots of interesting functionality including a well written plug-in system.

http://xmonad.org/

Re: Ask HN: What source code is worth studying?

#73
post #33

If you're an iPhone developer, Joe Hewitt's three20 is the best open-source codebase I know of: http://github.com/joehewitt/three20

Three20 is really useful. It's also quite powerful. But I wouldn't recommend it to someone trying to learn/study idiomatic Cocoa.

Joe tends to do things his own way, which works out fine, but does tend to depart from most people's Cocoa/Touch code.

Re: Ask HN: What source code is worth studying?

#74
post #43

Qmail: http://cr.yp.to/qmail.html 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…

More of crazy Whitney code available at http://aplusdev.org

Re: Ask HN: What source code is worth studying?

#75
I've heard this book was good http://www.amazon.com/Beautiful-Code-Leading-Programmers-Pra.... It asks 30 different developers for pieces of beautiful code. I read an excerpt or two back when it was released and put it on my to read list. Unfortunately haven't gotten to it yet, but still plan too.

Re: Ask HN: What source code is worth studying?

#76

One way to find code worth reading is to select inspiring developers and look at their code. Most of the developers in "Coders At Work" for example, have Open Source code we can look at learn from. 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…

For haskell I would recommend Xmonad. The code is short, lots of interesting functionality including a well written plug-in system. http://xmonad.org/

Xmonad is nice code indeed. For an introduction to a piece of it, check out Simon Peyton Jones's talk at OSCON 2007 - he uses Xmonad code as an introduction to Haskell, which gives you a taste of how the program is constructed.

Re: Ask HN: What source code is worth studying?

#77
post #54

I'm going to get downvoted for picking a non-open source option but... 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…

All the more heartbreaking that it was forced to don the hideous mantel of the Win32 API (itself further scarred from numerous assaults such as C2 compliance!)

Re: Ask HN: What source code is worth studying?

#79
post #54

I'm going to get downvoted for picking a non-open source option but... 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…

I spent several years writing drivers for NT and I don't know which part of the NT kernel you were looking at. The parts I saw were an utter mess lacking any sort of elegance whatsoever. If there were two ways to implement something, one simple and the other one contrived, you can bet your MCSD certificate NT will be using the latter.

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.

Re: Ask HN: What source code is worth studying?

#80
post #67

Earlier quoted context omitted.

for an easier time, your favorite language interpreter's source code ... interpreters are easier to comprehend than compilers, since you can 'follow along' with the flow of execution in the main interpreter loop just like you're executing a program ... e.g., creating stack frames, allocating heap memory, assigning variables, etc.

This really depends on the language. Ruby's code is (or at least was) quite nice. It is pretty much OO written in plain C. 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.

Yeah, after hacking with perl for a while, i got interested in how it worked under the hood, and had some trouble following.

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

Post reply on HN