Live data from Hacker News

Ask HN: What source code is worth studying?

news.ycombinator.com

61–70 of 117 posts

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

#61
post #39

Quake source code: www.idsoftware.com/business/techdownloads/ 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.

I'm still pretty wet behind the ears, but looking through Quake source (and quake 2), was quite the experience. I though the code was beautiful, as well as impressed with how DRY everything seemed to be....oh, and variable naming, small things like that, really impressed me.

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

#62
post #60
post #7

The Linux kernel: http://miller.cs.wm.edu/

Equally or more valuable than trying and sit down to read the kernel source is to follow the patches and discussions thereof on the linux-kernel mailing list: http://lkml.org/ 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 ta…

I don't treat is a novel, but a reference. I'll often wonder how certain things are implemented, and I'll poke around for the data structures and algorithms until I gain some understanding of how it works.

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

#64
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 agree that it's very beautiful code. I wouldn't go as far as "the most beautiful I've seen", personally, but it's really, really good. Also, when you come to it, you're typically shell-shocked from reading lots of crappy Win32 code, and it's just such a nice change.

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

#67
post #14

Your compiler's source code. That should shake your confidence in the world.

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.

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

#69
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…

The NT kernel is the most beautiful piece of code I've seen

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 ;>

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

#70
post #39

Quake source code: www.idsoftware.com/business/techdownloads/ 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.

Check out this recent analysis of parts of the source: http://www.fabiensanglard.net/quakeSource/
Post reply on HN