└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # code-canon 2 | 3 | You've probably seen calls for recommendations for good code to read 4 | and study. When this comes up on aggregators and stackoveflow, the 5 | result is pretty scattershot. Here is my own list, with only code I've 6 | read enough of to judge as in some way interesting. 7 | 8 | Canonizing my personal recommendations is a little fraught, since I 9 | know some of the authors and potential authors. Don't take an omission 10 | as much of a signal; we all have finite time, biases, and different 11 | goals and tastes. I'd love to get suggestions, by pull request or 12 | otherwise. 13 | 14 | Hopefully I'll add critical remarks, though I'm lazy. 15 | 16 | ## Counterpoint: other lists, commentary, and tips 17 | 18 | (An exception to the my-own-judgement rule.) 19 | 20 | * http://www.gigamonkeys.com/code-reading/ 21 | * http://www.hanselman.com/blog/CategoryView.aspx?category=Source+Code 22 | * Code Reading: The Open Source Perspective http://www.spinellis.gr/codereading/ 23 | * Ask HN: What source code is worth studying? https://news.ycombinator.com/item?id=7602237 24 | * Ask HN: Good python code for code reading https://news.ycombinator.com/item?id=327710 25 | * https://python-guide.readthedocs.org/en/latest/writing/reading/ 26 | * http://c2.com/cgi/wiki?ProgramsToRead 27 | * http://programmers.stackexchange.com/questions/38874/where-do-you-go-to-read-good-examples-of-source-code 28 | * http://c2.com/cgi/wiki?TipsForReadingCode 29 | * http://www.quora.com/Where-can-a-programming-beginner-go-to-read-good-code 30 | * http://www.readingcodegood.com/ 31 | * http://www.sitepoint.com/reading-ruby-professional-development/ 32 | * http://lukego.github.io/blog/2012/10/24/readable-programs/ 33 | 34 | ## Peter Norvig 35 | 36 | (I've contributed in small ways to several of these.) 37 | 38 | * http://norvig.com/paip.html 39 | * Java, Lisp and Python Essays at http://norvig.com/ 40 | * IPython notebooks http://norvig.com/ipython/ 41 | * "Design of computer programs" on Udacity https://www.udacity.com/course/design-of-computer-programs--cs212 42 | * on CodingBat http://codingbat.com/home/peter@norvig.com 43 | 44 | ## Kragen Sitaker 45 | 46 | * [kragen-hacks](https://www.mail-archive.com/kragen-hacks@canonical.org/index.html) has lots of interesting short programs. 47 | 48 | ## Barbara Liskov and John Guttag, Abstraction and Specification in Program Development 49 | 50 | It's hard to find good models of contracts and invariants driving and 51 | documenting code. This book with its examples taught me this. 52 | 53 | ## Kernighan and Pike, The Unix Programming Environment. 54 | 55 | So old-school it’s practically prehistoric, but the best book I know 56 | on the philosophy of Unix (with the possible exception of ESR’s The 57 | Art of Unix Programming, but that book has hardly any code, and thus 58 | is not so relevant to this question). The longest example is a small 59 | programming language with a compiler and VM interpreter developed in 60 | stages. http://cm.bell-labs.com/cm/cs/upe/ 61 | 62 | ## Kernighan and Plauger, Software Tools in Pascal. 63 | 64 | Develops variants of a bunch of classic Unix tools, back before Unix 65 | became 66 | popular. http://www.amazon.com/Software-Tools-Pascal-Brian-Kernighan/dp/0201103427 67 | 68 | ## Aho, Weinberger, Kernighan, The AWK Programming Language. 69 | 70 | Many surprisingly interesting and compact examples. (E.g. a ‘make’ in 71 | half a page of code, an assembler and interpreter, a command-line 72 | database system, etc., etc., etc.) Code is available for download, but 73 | it’s best with the book, which is unfortunately ridiculously expensive 74 | these days. http://cm.bell-labs.com/cm/cs/awkbook/ 75 | 76 | ## Chris Okasaki, Purely Functional Data Structures. 77 | 78 | Just what it says, with code in Haskell and ML. Not your parent’s 79 | data-structures book. http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf 80 | 81 | ## Donald Knuth, Literate Programming. 82 | 83 | Has a few extended examples doing neat 84 | things. http://www-cs-faculty.stanford.edu/~knuth/lp.html 85 | 86 | ## Mark Jason Dominus, Higher-Order Perl. 87 | 88 | Ideas from the functional-programming world brought to Perl. The 89 | longest example is a constraint-based domain-specific language for 90 | diagram drawing. http://hop.perl.plover.com/ 91 | 92 | ## James F. Gimpel, Algorithms in Snobol4. 93 | 94 | An overlooked classic with lots of fun code in a terribly obsolete 95 | programming language. Emphasis on string processing. Hard to find. The 96 | code is available online but probably hard to get much benefit from 97 | without the book. http://www.amazon.com/dp/0471302139/ 98 | 99 | ## Paul Graham, On Lisp. 100 | 101 | Fine examples of the power of Lisp. The best chapters on macros I’ve 102 | seen anywhere. His programming style is not so much to my taste 103 | (favoring too-abbreviated global names, anaphoric macros, etc.) but 104 | still interesting and educational. 105 | 106 | http://www.paulgraham.com/onlisp.html 107 | 108 | ## Peter Seibel, Practical Common Lisp 109 | 110 | http://en.wikipedia.org/wiki/Practical_Common_Lisp 111 | 112 | ## Richard O'Keefe, The Craft of Prolog. 113 | 114 | A bit of a grab-bag but a tasteful exposition of ideas and examples 115 | relevant to functional programming as well as Prolog. O'Keefe is 116 | entertainingly opinionated, not unlike Snape at Hogwarts when a 117 | student screws up. http://www.amazon.com/dp/0262150395/ 118 | 119 | ## Leon Sterling (editor), The Practice of Prolog. 120 | 121 | A collection of articles, each an extended example, with code, of 122 | making Prolog do something interesting, usually something 123 | AI-ish. Chapters by O'Keefe, Chris Mellish, Sterling, 124 | others. http://www.amazon.com/dp/0262193019/ 125 | 126 | ## P.J. Plauger, The Standard C Library. 127 | 128 | A full, portable, clean, reasonably efficient implementation of the 129 | (C89) standard library, with discussion of the design tradeoffs. Includes 130 | the relevant pages from the standard. 131 | http://www.amazon.com/dp/0131315099/ 132 | 133 | ## Edsger Dijkstra, A Discipline of Programming. 134 | 135 | Lots of small but nontrivial examples of developing a program and its 136 | proof of correctness 137 | hand-in-hand. http://www.amazon.com/dp/013215871X/ 138 | 139 | ## https://github.com/rswier 140 | 141 | I've read https://github.com/rswier/c4 but not 142 | https://github.com/rswier/swieros 143 | 144 | # Others' suggestions, or otherwise pending 145 | 146 | * [Physically Based Rendering: From Theory to Implementation](http://www.pbrt.org/) 147 | * [Lisp in Small Pieces](http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiSP.html) 148 | * [Implementing Elliptic Curve Cryptography](http://www.manning.com/rosing/) 149 | * <your favorites here> 150 | --------------------------------------------------------------------------------