Ask HN: Is "The Art of Computer Programming" worth investing in?
a love letter to the art<p>you can roughly split the art of computer programming as currently written into ten major arcs, each around 300–400 pages (including the answers to exercises):<p>1 introduction (math prerequisites, assembly programming)<p>2 data structures (lists, stacks, queues, trees, memory allocation, etc.)<p>3 random numbers (generating random numbers, testing for randomness)<p>4 arithmetic (floating points, polynomial arithmetic, etc.)<p>5 sorting<p>6 searching (comparisons, hashing, etc.)<p>7.1 binary tricks (includes binary decision diagrams)<p>7.2.1 generating combinatorial structures (combinations, permutations, partitions, etc.)<p>7.2.2.1 the exact cover problem<p>7.2.2.2 satisfiability<p>now, in any other book, each of these parts would maybe be 50 pages or so, and the whole thing would fit in one 500 page book. but don knuth is interested in the art, and the art is in part about understanding things as clearly as possible. that means understanding at an instruction by instruction level what is happening in the machine, and finding the appropriate mathematical structures that give insight into what algorithms are really doing. don is interested in thinking and writing as clearly as possible, but without sacrificing detail and resorting to handwaving. this is a difficult balance, because the material itself is hard.<p>this means that when don wants to understand sorting, he devotes 50 pages to the mathematics of permutations (section 5.1), and that he creates an idealized RISC-V architecture (MMIX) with a meta-simulator that supports all sorts of pipelining, caching, virtual address translation, etc. systems, so that he can count the exact number of memory accesses made at the machine level, so as to analyze a sorting algorithm. this means that when he wants to investigate combinatorial structures like graphs, but lacks a good class of test cases, he goes off and writes a 600-page book (The Stanford GraphBase) so that he can have consistent example data for writing about graph algorithms.<p>another part of the art is to gain an appreciation of the tapestry of human thought as it is woven through the centuries and millennia. don does his best to trace the roots of ideas, carefully studying all sorts of manuscripts from the past, in German, Latin, French, and really anything he can get his hands on. he traces the full names in their original languages of all people mentioned in the art, with the index of volume 4A spanning 50 pages. section 7.2.1.7 explores the history of combinatorial generation through old Chinese manuscripts, Sanskrit prose, the meter of Greek poetry, and so much more, showcasing the spirit of the programmer as it goes back hundreds of years before the advent of the program.<p>much of the art lives in the exercises. there are more than 4000 of these exercises throughout the art; many sections ending with at least 50 of them. many of these exercises are an entire research paper, where don has digested it, as well as the papers surrounding it, and provides in the exercise a skeleton of essential ideas that gave life to the paper, leaving you to coat those bones with flesh. he reads a hundred papers or so before writing each section, working in what he calls “batch processing”, and studying in chronological order the papers that form the lineage of a topic from genesis to present day.<p>the art is a living work. the third edition of volume 1 has gone through 52 printings since 1997, and many more printings if we count from the first edition of 1968. since 1968, don has read through thousands upon thousands of letters from readers, with comments ranging from suggestions for new material, to petty remarks like “i think this comma here should be a semicolon instead.” he will read it all and think it through, because he wants to get it right. he then scribbles his reply in pencil to your email printed out, and you get it back by snail mail half a year later, with a reward ‘check’ if he used your suggestion. every printing incorporates many little changes all over the place, and no two printings of the art are the same. just last week he inserted a new exercise into section 1.3.3 for the 53rd printing of volume 1, to anticipate new material in 7.2.2.8 he just wrote on decoding the Enigma machine (<a href="https:&#x2F;&#x2F;www-cs-faculty.stanford.edu&#x2F;~knuth&#x2F;fasc9b.ps.gz" rel="nofollow">https:&#x2F;&#x2F;www-cs-faculty.stanford.edu&#x2F;~knuth&#x2F;fasc9b.ps.gz</a>), as an example of applying backtracking.<p>the art is the pursuit of beauty. after the galley proofs for the second edition came back in 1977 with shoddy typesetting, he spent a decade on TeX, because, well, the letters have to look right in the words, the words have to look right in the paragraphs, and the paragraphs have to look right on the page. and part of beauty is fun, without the search for applications. volume 4b is full of puzzles with little attempt to justify their utility — master the art, follow the beauty, and utility will come along naturally later.<p>the art is a love letter to the spirit of computation, written with the nothing less than the entire life and force of don knuth. and that’s a lot — don knuth works really, really hard, and he continues to write the art at the age of 85 today (he’s now writing 7.2.2.3).<p>so you ask, should you read the art? i say: if you are longing to find, to understand the beauty in these ideas, and to really come to see the very pulse of the machine. goals of utility and efficiency will not be best served here — there are many better books for such purposes — for to view through this lens the art, it would perhaps amount to mere diminishing returns. (that said, you will certainly be a better programmer if you read his book! it might just take a while.) don wants to get it perfect, as perfect as a human work can be, and has spent his life seeking this beauty. the art is his adventure logs, and thank God he should have chosen to share them with the world.