Ask HN: Is the “The Art of Computer Programming” Worth the Investment?

141 points by main_c ↗ HN
Reading through and taking in "The Art of Computer Programming" seems to require massive amounts of time investment. In your opinion is the gems inside the text worth it?

69 comments

[ 4.0 ms ] story [ 126 ms ] thread
I spent three years reading the first three and (attempting, at least) every exercise. I enjoyed it, but I don’t know if it made me a better programmer. I definitely did learn a lot, although maybe not that much that was really practical.
I think your posts on this topic are worth linking to:

- Reflections on a year of reading Knuth https://commandlinefanatic.com/cgi-bin/showarticle.cgi?artic...

- Reflections on another year of reading Knuth https://commandlinefanatic.com/cgi-bin/showarticle.cgi?artic...

- Reflections on Three Years of Reading Knuth https://commandlinefanatic.com/cgi-bin/showarticle.cgi?artic...

These are awesome. Thanks for posting.
Thanks. I feel like I shouldn't link to my own blog on here myself, but yes - these are my thoughts as I finished each volume.
Jesus man, please link to this great work! Humility be damned
Agreed. I don't think there is anything wrong with linking to one's own posts here, if they are relevant. I do it now and then myself.

BTW, commandlinefan, your page:

https://commandlinefanatic.com/cgi-bin/showarticle.cgi?artic...

has the right pane text overlapping the left pane (main body of post), at least when I increase the font a bit with Ctrl=+. (Chrome, Windows). Please check and fix if can.

It happens for the other two posts about reading Knuth too. But not for your About page. FYI.

I have never found anything professionally useful in “Seminumerical Algorithms”, but Knuth’s writing is clear and concise that I go back reread the parts which I just found interesting.

(In particular I love why numbers with lower initial digits are more ‘common’ than others, and tests for randomness.)

I used it in pre-internet days to write BCD multiply & divide routines.
While I was reading those chapters I thought, I'll bet the people who implemented, say, the Java standard library would have spent a lot of time reviewing these chapters. Later I noticed some comments in the Javadoc for the Java standard library that refer back to TAOCP, so I guessed correctly ;)
Minor typo in the Reflections on 3 years of reading TAOCP.

> Quicksort is O(log n)

Should be

> Quicksort is O(n log n)

Oops. Lucky for me I don't send out Knuth cheques of my own ;)
Might come up in an interview someday.
As in the interviewer asking the interviewees whether they have read TAOCP? :-)

Yes, I am jokingly referring to the Bill Gates blurb about the book on the cover of later editions of TAOCP.

Almost anywhere on the internet people will respond to this with basically "no, it's extremely inefficient to learn how to program this way", and they're right.

But.

If you want to learn _other_ things, these books are incredible. Maybe you want to learn deeply the combinatorial ideas behind data structures, or general techniques for squeezing small optimizations out of low level code. Or even maybe you want to see simple data structures used every-which-way to efficiently solve a huge range of mathematical problems. None of this is normal programming per se. I treat these as math books, and love them for it.

Like much of mathematics, it will make you a better programmer, but only accidentally.

Think of the series like a detailed, focused encyclopedia. You can learn an incredible amount from reading and understanding it, but reading the whole thing is probably not especially efficient, and it will likely take a long time.

That said, you didn’t really set any goals; you just asked if it’s “worth the investment”. That’s very abstract, and to that I would say “yes”, but also “it’s very likely that you’re not at a point in your life that reading the series, especially cover to cover, is the best use of your time”.

Hope that helps.

> “it’s very likely that you’re not at a point in your life that reading the series, especially cover to cover, is the best use of your time”.

Genuinely curious, when would it be the best use of my time? Is there any scenario where "Read TAOCP and gain X superpowers" would hold true? I have been wanting to get into this for some time now because I like the idea of intellectual pursuit but I also hoped that some benefits, however incidental, would carry over into my career.

Sounds like it would be great for a bored mathematically-inclined high school student with an interest in programming who is also pretty confident that they can get into the college of their choice.
Offhand, I’d suggest reading it over a long period of time, starting whenever you feel like you have a good mastery of whatever project you’re working on at the time, and taking breaks to rest or sprint on need-it-nowish topics in between.

The benefits of understanding how computers work at low levels, how algorithms work and are built/studied/compared, and how data structures can change how you think about programs and processes (to call out a few barrel-sized buckets) are likely to be helpful over the long term, while the likelihood that you happen upon the key thing that you need today (or this month) at just the right time is pretty low.

Either way, don't miss the parallel-psychology analog: Write your own.

Be it ever so humble, it will be yours and it will grow in leverage the more you test, update, organize, and refine it.

A good way to start is to write down things you've already learned about computer programming. Then get ready to start organizing and updating this information over time.

Pretty soon you'll find that you start on new projects faster and save lots of time and energy.

Mine would be titled "The Arse of Computer Programming".
I mean I personally like that title and would at least give it a thumb-through if I saw it in a store. But hopefully you have some ISBNs to burn. ;-)
Depends on what you mean by “worth it”.

In the monetary sense? Depends highly on your particular specialization.

In the intellectual sense? I own a copy, have read selected chapters. Perhaps. Are you planning on doing all the exercises, as if in a class?

To know whether you'd enjoy it (which is the only measure of “worth it” I can think of in relation to this book), you could start with one of the recent sections on combinatorial algorithms (Volume 4A and part of Volume 4B have been published so far): http://www.cs.utsa.edu/~wagner/knuth/

For example, 7.2.1.2 on generating all permutations (http://www.cs.utsa.edu/~wagner/knuth/fasc2b.pdf) has a lot of cool mathematics, some low-language programs, some alphametic puzzles, .... Or 7.1.4 on Binary Decision Diagrams (http://www.cs.utsa.edu/~wagner/knuth/fasc1b.pdf) is on a little-known (IMO) data-structure presented in Knuth's unique way, which can solve many counting problems.

Stepping back a little, there are two ways you could read this book:

• Try to engage with the mathematics, try each exercise for at least half an hour before giving up and looking at the solution, etc. (Doing it this way can definitely be a massive time investment.) If you'd like to do this, and find the mathematics difficult, you should read Concrete Mathematics which Knuth co-wrote with Ron Graham and Oren Patashnik, which is a highly enjoyable book in itself.

• As mentioned in a recent post (https://nickdrozd.github.io/2019/05/17/knuth-check.html):

> By the way, if you’ve ever thought about reading TAOCP, give it a try. A lot of people will tell you that it’s a reference work, and it’s not meant to be read straight through, but that isn’t true. The author has a clear point of view and a narrative and an idiosyncratic style, and the only thing that inhibits readability is the difficulty of the math. There’s an easy solution to that though: read until you get to math you don’t understand, then skip it and find the next section you can understand. Reading this way, I skip at least 80% of the book, but the remaining 20% is great!

You could even do the latter first, then the former. It's really up to you, and diving in and trying a chapter or two is the best way you can judge whether you'll find it an enriching experience. (BTW: Knuth mentions in some interview that he wanted to call the books “mathematical analysis of algorithms”... if you're thinking that the books are trying to define the art of computer programming and will make you a better programmer at the kind of programming tasks you're likely to encounter in a professional career, then it's probably not the best use of your time... which is why I mention reading it for yourself and seeing if you like it; IMO the books are really enjoyable and full of clarity and grace and humour and depth.)

I have been wanting to read them for long. But right now they just look nice in my bookshelf.
Rather start with Concrete Mathematics (also by Knuth and friends). If you don’t like that book, you will probably hate TAOCP. It also covers the requisite mathematics that you’ll need for working through TAOCP.
I like Concrete Mathematics, and jumped into it while going through Chapter 1 of TAOCP. However, I wouldn't consider an opinion of CM when considering TAOCP. The first part of Chapter 1 of TAOCP is very math heavy. Concrete Mathematics was developed from a course meant to expand on that content and prepare students better for it. While the style is very similar between the two books (Knuth was an author of both, of course), the content is very different. TAOCP is probably more accessible to programmers who have an aversion or difficulty with the math in Concrete Mathematics and shouldn't turn away just because a math book is challenging or not their interest.
Will you be on your deathbed thinking "I wish I read another tedious computer book?" If so, then yes! Seriously though, probably better things to be done than work through Knuth books in my experience.
In my experience tedious computer books are published by Packt. TAOP warrants another adjective.
Tedious: "too long, slow, or dull; tiresome or monotonous." -- TAOP qualifies, for me anyway. Have fun if you like it.
Well I don't own it but have access to a copy from my office library. I must say that reading it cover to cover is time taking but if you use it as a reference to lookup algorithms and stuff, it is really enlightening.
Are the complete works of Shakespeare worth the investment? Yes, but you might consider if you can read most of it and drop Cymbeline and Pericles, Prince of Tyre.
You can put them in your library/desk to impress your friends
I keep mine in clear view on the shelf in the hope that its collected wisdom will radiate outward and suffuse into my code. Not happened yet, but perhaps it has a useful psychological effect as a shrine to algorithms; whenever I am tempted by a quick, cheap hack I see the books and am steered back to the righteous path.

Actually I usually just do the cheap hack anyway but it is reassuring to know that it is there.

I suggest to work through some introductory chapters to learn MIX and then glance over the books to be aware what topics they have. Probably read some interesting chapters just to enjoy. So when you need to implement something that's covered, you can quickly read the information.

Reading it from start to end IMO is overkill, unless you want to be algorithm encyclopedia.

Though most developers can just skip it, because they won't need to implement any complex algorithm ever.

You can buy my copy. :-)
i prefer more specificly targeted books. These are very general and thus suffer from the critique that it's inefficient or hard to learn (as it's perhaps to broad for 'their' use cases or learning path).

if you want to learn in general more about computer programming ,go for it, its good. if you want to learn specific sub topics within computer programming, of which there are many, consider getting a more specialised book.

as example. for me i like to go low level and code in C on some hobby operating system. most information in most programming books is rubbish for that. but specific books targeting intel/amd execution environments, architecture and assembly basics have helped me ALOT. - other books still help me out, and teach me things, but specific books help me directly implement things into my current project which is to me more useful.

Just as a remark: I think the volume on searching is in need of an update in this age of search engines.
This book is not to accomplish a quick skills upgrade to boost your career. This book is meant to take you on a very long and extensive journey into fundamentals. Probably you will not make any more money from reading it in the short term, probably you will not even be a better programmer instantly. But with time, it will change the way you think and it will bring you a deep understanding of our subject's base.

TAOCP is no howto, no tutorial. For the subjects it covers, it is a meditational bible.

For me its worth reading just for entertainment. Personally I skim a lot of the maths, and I think most of the exercises are for people with maths degrees. I don't have a hope of doing them. Regardless, its a good read - very well written, fascinating if you have an interest in algorithms. And beautifully presented too.
I recommend to read or even do the mathematical preliminaries, or whatever it is called. The first section(s) of Volume 1 represent 40 pages of very carefully compiled math fundamentals.

I'll read it again when I have the time. The other stuff is admittedly too difficult for me.

If it won't be any worth.

This wouldn't be mentioned by Bill Gates “If you think you’re a really good programmer… read Art of Computer Programming… You should definitely send me a résumé if you can read the whole thing.”

Currently most of engineers have to do application development where you rarely come across of any need to use this knowledge. But for being computer engineer and if you think all these coding challenges, the concept of these books is still relevant. Books on competitive coding take excerpt from that book only.

It is a daunting task to complete but it will show its worth over time.

> This wouldn't be mentioned by Bill Gates “If you think > you’re a really good programmer… read Art of Computer > Programming… You should definitely send me a résumé if you > can read the whole thing.”

I don't think Bill meant it seriously....he never responded when I sent him my resume 20 years ago :-)

It is fun to read. It is more of an armchair read than a "studying book" or a manual. I guess most of the advanced techniques in, for example, memory management, have already been improved but you will learn a lot and enjoy it.

I would not recommend it for studying, though.

It genuinely pains me to say this, as I've got a copy on my bookshelf, but no.

Reverence for it is religious/romantic in nature, and neither based on practical nor pedagogical means.

If you want to build practical skills and experience with algorithms, choose a problem domain involving them and dive straight into it.

If you want to expand your mind/skills, choose a programming language from a paradigm and do everything in it for a few years. Then once you've got it all figured out, choose a deliberately different paradigm and do the same thing. Repeat for 3-5 rounds.

Sure, there's nothing technically or factually wrong with the book. I had to look up some algorithms in it once for a reference and implemented it from that source, and Knuth writes clearly enough, but if someone wanted to learn english, or wanted to know how to improve their english, i similarly wouldn't direct them to read an old dictionary.

Edit 1: If i had to recommend books, aside from the observation that there's relatively few that i'd actually recommend with the goal of making one a better programmer explicitly, I've learnt more from lisp books and/or trying to apply languages to project euler or personal projects than I've ever picked up from TAOCP...

Edit 2: oh, and trying to improve and implement all the things that people tell you not to bother trying to improve and/or implement...

This is a series more for engineers who want to delve into the depths of "computer science" that takes them to the magical world of mathematics. That way, its not worth if you are looking for direct real world application, like the CLRS or Sedgeick books provide.

That said, I think its worth having this for the humbling experience it provides. This experience is very much needed for every engineer, and specifically software engineers, because after a while of reapplying same old tropes to churn out solutions to problems, there creeps a feeling that we are at the top of our game, and "experts", when in reality most of us are only "experts" in a specific insipid framework or technology which are as permanent as the latest fashion trends. This series of books makes us feel worthless and keenly introspect. It makes us see that there is a vast array of knowledge that we severely lack. It builds personality and keeps us grounded. It separates true musicians from college band guitarists who shred the neck to cheering crowds.

I have Combinatorial Algorithms Part 1 Volume 4A and it makes me cry every time I peruse it.

If CLRS is an example of sonething that has direct real world application, then the other must be truly arcane and esoteric. My hatred for CLRS mostly stems from a completely terrible algorithms class I took which used it, ignored anything that might be useful, and focused 110% on proof-writing. For all the random crap that is covered in excruciating detail, there are some weird gaps where some things that are actually used in industry and have long been, don't get passing mention...

But Corman himself is also kind of a pretentious tool, so that doesn't help - he was certainly an abysmal freshman advisor.

What enraged me about CLRS was that none of the exercises included answers. I'm not asking for fully worked-out solutions - just something I can gauge my own work against. ("I got 5. The back of the book says 12. Ok, I must have made a mistake somewhere...") The hostility that the authors direct at people who are looking for a quick sanity check like that fits into your observation that C is a pretentious tool.
How is proofwriting not useful? What do you expect in an algorithms class? It’s called algorithms, not Python Frameworks or something.
I had hoped that we might write at least one line of executable code to actually implement any of the algorithms that we studied.

I think the same course could have been much more useful and even fun if you had to turn in working C code in addition to all the pen-and-paper work.

Algorithm Design by Tardos/Kleinberg is a much better book for this imho, going through 200+ problems and designing algorithms to solve them. Less reference style than CLRS and more like TAOCP.
Hahaha that is a great story. Though it does seem like teaching and advising are different skills and one can be good at one but not the other.

I have been watching Steven Skiena's lectures and reading his book, and I like both of them, but the lectures most of all because of his relaxed and practical approach. Skiena himself says that CLRS is a "better" book than his (and also more up to date) but I like the Skiena learning curve better.

In contrast, Tim Roughgarden's lectures and books are more mathematical, but his proofs seem reasonably well-motivated and clearly explained to me at least.

I also like how both of these guys point out that coming up with new algorithms or proofs from scratch is incredibly hard and you shouldn't expect (yourself or anyone) to be able to do so quickly or on the fly. Success with algorithm puzzle exams, algorithm puzzle "programming" contests, and algorithm puzzle "technical" interviews is largely based on familiarity with a large body of pre-existing algorithms and data structures and experience applying them to a wide range of problems. That sort of knowledge and experience greatly improves your odds of guessing the (often sneaky and non-obvious) trick required to solve a particular, usually weirdly stated, algorithm puzzle.

Alternately, I implemented the algorithm for generating all permutations straight out of Knuth.

They may be extremely dense and hard to read, but I feel like you are hanging a lot of emotional baggage on a set of reference books.

>I have Combinatorial Algorithms Part 1 Volume 4A and it makes me cry every time I peruse it.

Is that a recommendation or anti-recommendation? Or both?