Ask HN: Good code to read for a beginner
It seems a bit of a catch-22 though, as I don't believe myself (or any other beginning programmer) to be able to discern worthwhile code for review.
That understanding in place, what are some of your suggestions for good code to read to get a feel for style and technique?
Note: I am working through MIT's OCW CS material (still pretty beginner), and have picked up a pretty decent smattering of Python and Scheme thus far. These languages (including Common Lisp - I recognize that there are large differences between Scheme and CL, but I think I should be able to get the basics) would be most useful for me as I already have a pretty good foundation in them, but don't hesitate to suggest good programs in other languages, as I will need to learn more at some point, and hopefully others will find this thread useful.
[0]http://www.catb.org/~esr/faqs/hacker-howto.html#skills1
14 comments
[ 3.4 ms ] story [ 41.2 ms ] threadI feel like there's a gap between "Here's looping, conditionals, IO, OO basics, functions, etc..." and being able to write something useful. Everywhere I look seems to fill the gap by saying "Go read code" or "Hack on things you use". I'm trying to answer the first part here, and the latter leads me to very large programs that I can't really digest yet.
I've worked on a couple simple programs for myself, but typically end up thinking about how trivially I could implement it on an RDBMS (I work in BI consulting - I write SQL for half of my work), but understanding that that would be overkill. E.g. I'm working on a simple task tracking program that captures basic metadata that would be useful in capturing billable hours. I could write up a basic schema and some stored procedures in a few hours, but then I'd just be punting all the hard stuff to the DB and not improving.
I don't see the need to worry about style if you're a beginner.
Do you have any recommendations for a starting point for any of these algorithms. My first shot would probably just be trawling Wikipedia, but if there's a better place to look I'm all ears.
http://rosettacode.org/wiki/Sorting_algorithms
http://rosettacode.org/wiki/Category:Data_Structures
Once you're at an intermediate level in any language and experienced with programming concepts in general, then it does make sense to develop good coding style (by reading books and blogs about the topic) and adopt idiomatic practices of the community (if they're sane). But simply reading a large codebase to become a better programmer is drinking from a firehose. It might make sense for an experienced programmer, but usually you'll do that because you're working on the codebase.
http://underscorejs.org/docs/underscore.html
http://backbonejs.org/docs/backbone.html
It'll probably have some great code and some rough edges. It's okay. Learn how to get shit done and learn elegance, too.
Or you could pick a common theme and look at various implementations of it. Look at twitter api libraries and see how they differ, perhaps?
http://www.gigamonkeys.com/book/