Ask HN: What source code is worth studying?
403 pointsThis is one my favourite questions, asked by idlewords: https://news.ycombinator.com/item?id=879101
But its been a long time since then, and with a new set of programming languages, I believe there are new code bases that's worth studying about and learning from.
So, which code-base should I be reading about to improve myself?
Comments (166) 76 threads
Earlier comments[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 game written in 1K of highly obfuscated code, which the author expands upon here. Worth it because it teaches some crazy optimisation techniques that are applicable to all programming, but also includes plenty of javascript-specific trickery. http://marijnhaverbeke.nl/js1k/
http://norvig.com/sudoku.html
As Ravi said:
Ron Jeffries attempts to create a sudoku solver – here, here, here, here and here. (You really ought to read these articles. They are ummm…{cough} …err…. enlightening.)
Peter Norvig creates a Sudoku Solver.
Compare. Learn.
http://ravimohan.blogspot.se/2007/04/learning-from-sudoku-so...
Looking at their GitHub now I must admit that the source code and comments look pretty good.
I was mostly looking for Python, Javascript, Haskell and C#. Any help regarding that?
Also, as I believe this thread will also help others, you can go ahead and post about any other code-bases for other languages.
Here is a link to cpython 2.7 libraries: http://hg.python.org/cpython/file/70274d53c1dd/Lib
Those that are implemented in C are in the "Modules" folder from the top level.
I think you [OP] will get the most benefit from reading libraries that you use often because it will give you some direction.
If there are 3rd party libraries you use heavily those will be interesting too.
It is very very difficult to just pick up megabytes of code and start reading them and find it useful. You will be able to pick up style and conventions but not really high-level engineering decisions.
My suggestion is to take software that you use regularly and run it through a debugger. Since you use it you know the problem domain. And with the debugger the code you're reading gets real context. I've done this with Git for example.
And also look at the design documents for big OSS projects.
If you do dive into merb, one of the contributors started a handbook on internals long time ago (https://github.com/michaelklishin/merb-internals-handbook), although, it died with the merb itself.
All comments shown.
Couldn't load more comments. Check your connection and try again.