Live data from Hacker News

Ask HN: What source code is worth studying?

news.ycombinator.com

61–70 of 176 posts

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

#61
post #35

Slight tangent to your question, but one thing I have noticed recently is that having to deal with really crap code inspires me to do my own better. I inherited a colleagues work after she left, and it was horrible. But I thought about why it was horrible, and how to make it better. What would it look like if it was done well? Even with my own code, if I look at something I did 6 months ago, and it doesn't make sense…

It frightens me how my future replacement is probably going to think "gee, that guy was horrible" unless he knows all the historic context and reasons why the code was written the way it was written.

> unless he knows all the historic context and reasons

That's what comments are for :) It's not only about your future replacement, it's also about your future self.

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

#63

C -> nginx C++ -> Chrome

When you read any C++ codebase remember that there are many dialects and so just because something is a good idea in one doesn't mean that it is in another and that you should prefer that way without understanding the reasoning behind it.

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

#65

== Vim or Emacs == Just pick one and force yourself to use it to the exclusion of other editors. Future you will thank you later, because you'll still be using it 20 years from now. "We are typists first, programmers second" comes to mind. You need to be able to move chunks of code around, substitute things with regexes, use marks, use editor macros, etc. == 6.824: Distributed Systems == http://pdos.csail.mit.edu/6.8…

>Do not identify yourself as "an X programmer," or as anything else. Yet every single programming job post these days is basically looking for someone with X years of experience in a long enumeration of specific technologies. The usual reason being "They need to be productive. Now."

I think that is also because hiring is generally busted, and recruiters who are not programmers don't know what else to ask.

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

#67
Slightly off topic, but Peter Seibel's take on the idea of code reading groups, and the idea of code as literature, is interesting: http://www.gigamonkeys.com/code-reading/

"Code is not literature and we are not readers. Rather, interesting pieces of code are specimens and we are naturalists. So instead of trying to pick out a piece of code and reading it and then discussing it like a bunch of Comp Lit. grad students, I think a better model is for one of us to play the role of a 19th century naturalist returning from a trip to some exotic island to present to the local scientific society a discussion of the crazy beetles they found."

The reason this is off topic is that it sounds like you were after interesting specimens anyway. I don't have any code examples as such, although if algorithms count I'm particularly fond of Tarjan's algorithm for finding strongly connected components in a directed graph, and the Burrows-Wheeler transform (as used in bzip).

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

#68

Earlier quoted context omitted.

>Do not identify yourself as "an X programmer," or as anything else. Yet every single programming job post these days is basically looking for someone with X years of experience in a long enumeration of specific technologies. The usual reason being "They need to be productive. Now."

In my experience, best jobs you get aren't posted — as best candidates don't send out resumes.

But we can't all be the best.

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

#69
post #62

I found the annotated source code of the underscore.js to be very educational: http://underscorejs.org/docs/underscore.html

I have to say that the annotation is very nice. Would be a nice feature for something like Github, assuming that developers care enough to do the write up. Might get messy for larger projects though.

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

#70

To mix things up a bit, I'm going to give two very small examples of code that can be understood quickly, but studied diligently. Both are in JavaScript, which I notice you mention specifically in another comment: [1] Douglas Crockford's JSON parser. Worth a look because it is excellently commented and is easily understandable https://github.com/douglascrockford/JSON-js/blob/master/json... [2] Bouncing Beholder. A ga…

Anything Javascript code from Crockford I highly recommend. Well structured and without "hacks" that could cause confusion.
Post reply on HN