7 ms·
Atwood wrote: "The idea that you'd settle down in a deep leather chair with your smoking jacket and a snifter of brandy for a fine evening of reading through so
by greenyoda 15y ago
Atwood wrote: "The idea that you'd settle down in a deep leather chair with your smoking jacket and a snifter of brandy for a fine evening of reading through someone else's code is absurd."
Not so absurd, really. Reading well-written source code is a great way to learn the finer points of the art of programming; it's not just for fixing bugs. In fact, entire books have been published that consist of annotated source code, the most famous probably being Lions' Commentary on Unix and Knuth's "TeX: The Program".
- kevinpet 15y agoEntire books have been published that consist of annotated source code, the least famous probably being Lions' Commentary on Unix and Knuth's "TeX: The Program", since they are pretty much the only widely distributed books consisting primarily of annotated source.
- Danieru 15y agoHow can they be the least famous if they are the only ones?
- abecedarius 15y agohttp://stackoverflow.com/questions/282470/which-books-have-really-interesting-source-code-and-explain-it-well http://stackoverflow.com/questions/282470/which-books-have-r...
- michael_dorfman 15y agoJust glancing over at my bookshelf, how about Tanenbaum's OSDI and Knuth's MMIXware?
- gjm11 15y agoI have at least three others on my bookshelves. (Two Knuths -- METAFONT and the Stanford GraphBase -- and Fraser&Henson's "A retargetable C compiler".) For sure, there aren't a large number of books with this structure. So what?
- andrewflnr 15y agoYes, it's educational, but generally not entertaining or relaxing, as is implied by the scenario of settling down in a comfy chair, etc. If code is entertaining, it's probably not the kind of code to learn good habits from.
- haberman 15y agoYeah, I do this frequently with the source code to Lua, which is an astonishing piece of software engineering that constantly inspires me. I can hardly think of another open source project that does so much with so little code.
- astrodust 15y agoI'm sure I'm not the only one that wants a good tool that would convert arbitrary source-code to Lulu-sized PDFs that could be printed on demand.
- rkuester 15y agoTry the command line program "enscript". It has many options that control the output formatting. For example, you can print pages in landscape orientation, two-up, with source highlighting and line numbers.
- akx 15y agoIf you also want coloring (I know I would), Pygments - http://pygments.org/ http://pygments.org/ - outputs PDF via LaTeX.
- enobrev 15y agoThe hard part is finding the "well-written source code". Sure there are plenty that have been battle-tested for years, which we can refer to, but every day we come across tens to hundreds of github links. Some are legible. Some are clever but maybe interesting. Some are in need of serious refactoring. Some are first-attempts. Some are "drunken rants" (usually < 10 checkins, with every file marked as 6+ months ago). And once in a great while, some are worth some serious attention. I "grew up" in PHP, and while the majority of the open source code I've read has been difficult to parse, at best, I've read some amazing code. Most from intelligent peers for whom I still hold a deep respect. It's what has kept me inspired. It's what brought me to eventually appreciate Javascript (server and browser), Actionscript (3), Java, Python, C, Ruby, a few others, most recently including Clojure. And when it comes to amazing code (regardless of language), I will gladly sit and read with more intrigue than the best fiction has to offer. It's the massive amount of mediocre or less that defines the divide making source code painful. I skim a lot. I look for whitespace, the occasional well-written comment block, proper variable / method naming, things to hint that this was written to be read by another human who likes to read, and from there I dig in deeper with the hopes that I have something worth reading. That is to say, I LOVE to read code, but it can be difficult to find the code worthy of the smoking jacket and voting-age scotch.