bbischof 5 years ago

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.

vinayms 5 years ago

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.

  • thrower123 5 years ago

    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.

    • commandlinefan 5 years ago

      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.

    • musicale 5 years ago

      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.

    • bigred100 5 years ago

      How is proofwriting not useful? What do you expect in an algorithms class? It’s called algorithms, not Python Frameworks or something.

      • thrower123 5 years ago

        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.

        • hackermailman 5 years ago

          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.

  • jpitz 5 years ago

    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.

  • musicale 5 years ago

    >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?

commandlinefan 5 years ago

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.

  • svat 5 years ago

    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...

    • commandlinefan 5 years ago

      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.

      • holografix 5 years ago

        Jesus man, please link to this great work! Humility be damned

        • vram22 5 years ago

          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.

          • commandlinefan 5 years ago

            Ah - I think I see it, thanks. Should be fixed now.

    • plinkplonk 5 years ago

      These are awesome. Thanks for posting.

  • JackFr 5 years ago

    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.)

    • peteri 5 years ago

      I used it in pre-internet days to write BCD multiply & divide routines.

      • commandlinefan 5 years ago

        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 ;)

  • thethirdone 5 years ago

    Minor typo in the Reflections on 3 years of reading TAOCP.

    > Quicksort is O(log n)

    Should be

    > Quicksort is O(n log n)

    • commandlinefan 5 years ago

      Oops. Lucky for me I don't send out Knuth cheques of my own ;)

ACow_Adonis 5 years ago

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...

c256 5 years ago

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.

  • ashwnacharya2 5 years ago

    > “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.

    • c256 5 years ago

      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.

    • solveit 5 years ago

      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.

svat 5 years ago

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.)

zvrba 5 years ago

Depends on your goals. For example, when writing a real-world application today, the standard library provides you with a "good enough" sorting and searching algorithms and dictionary structures. The whole 600+ pages of volume 3 are dedicated just to these topics. You aren't going to be a better "everyday" programmer after studying that book. (Though I'm not aware of any language that has radix sort in its stdlib :-))

However, they are a well of ideas as well as extensive treaties on "esoteric" topics (e.g., testing sequences for randomness, derivation of FFT, sorting networks, external sorting...)

Knuth has written that he plans to remove the section on external sorting from the next edition of vol 3 (if _that_ ever happens)… though think about the cache effects on modern CPUs: could we sort faster by thinking of the cache as "internal memory" and of RAM as a "tape or disk drive" and applying a decades old external sorting algorithm?

Similarly, most sorting routines rely only on less-than, but often your comparison routine returns -1, 0 or 1. I implemented string sorting in C++ using 3-way comparison (instead of just less-than) and it was actually faster!

The exercises and their answers are source of gems as well, even if you just look up the answer to use the result.

Also, I never read them cover-to cover. When I'm bored, I take one volume, pick a chapter/section and read it and skim through exercises, at the same time thinking of what that could be applied to.

  • KingMob 5 years ago

    The issue with thinking of RAM as a "tape or disk drive" is that a tape has linearly increasing access times, but RAM takes the same time to access any part, so this algorithm wouldn't be ideal. Even most of our external storage these days (flash, etc) is random-access. True O(n) access media are becoming more and more scarce, so I'm not surprised Knuth is removing it.

    • dragontamer 5 years ago

      > but RAM takes the same time to access any part

      This is provably false for common DDR4 RAM! Linear access to RAM is significantly faster, maybe 2x to 3x faster than random access in practice... maybe 10x faster in a theoretical micro-benchmark.

      This is partially due to pre-fetchers: modern CPUs will detect that you're accessing memory linearly, and then it will "prefetch" the data to the cache before your code even reads a location.

      Another aspect: any "Open Row" of RAM (roughly 1024-bytes worth) is accessed through a "Column Read", which is 2x faster than a "Row Read + Column Read", and maybe 3x faster than a "Precharge + Row Read + Column Read" (this last case is how random-access works).

      So a read to an already-open row is 2x to 3x faster at the DDR4 protocol level. The prefetcher increases gains to roughly 10x faster in special cases (but the prefetcher is "arguably cheating", even if it is quite reliable in sequential cases).

      Just using round numbers, but... yeah... random access should be between 2x to 3x slower if you test it. Its very simple to test too: just rand() across a big 2GB array that you malloc() and you'll see that the rand() traversal is SIGNIFICANTLY slower than an iterative traversal.

      ------------

      If you can "cheat" your algorithm to traverse memory sequentially, you'll find absolutely crazy gains. Bonus points: a linear / sequential algorithm can often be converted into SIMD-style code (possibly by the autovectorizer of the compiler).

      Sequential-access of RAM is one of those surprising micro-optimizations on modern computers. 1000% faster memory reads in some cases, I'm serious!

      -----------

      The L1 cache seems fully random to me in my tests. But the hardware prefetcher works even on L2 and L3 cache, so I'd expect sequential gains even if your data fits inside of L2 or L3.

      Oh, and don't get me started on the TLB. If you're on Windows or Linux (which use virtual memory, not physical memory), all pointer-dereferences goes through the Translation-Lookaside Buffer. If you have 4GB to 8GB of data on 4kB pages... random access would destroy your TLB and you'll suffer dramatic slowdowns as the OS will "pagewalk" the virtual memory directory on every dereference.

      Yeah... memory optimization favors sequential access in a huge variety of situations.

      • Breza 5 years ago

        This is the most fascinating thing I've read all day. Thanks for the information!

    • zvrba 5 years ago

      IIRC, these algorithms are based on merging, i.e., reading sequentially as much as possible. Therefore I wonder...

geff82 5 years ago

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.

themodelplumber 5 years ago

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.

  • nineteen999 5 years ago

    Mine would be titled "The Arse of Computer Programming".

    • themodelplumber 5 years ago

      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. ;-)

diegolo 5 years ago

You can put them in your library/desk to impress your friends

  • silverdemon 5 years ago

    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.

laichzeit0 5 years ago

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.

  • Jtsummers 5 years ago

    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.

hackermailman 5 years ago

It's not really a massive time investment. Consider people you see every morning doing a sudoku or crossword on a patio at a coffee shop or on a subway. That's basically what TAOCP is to me, a past-time/hobby, leisurely going through the psets and trying to do things like patch an ancient algorithm or solve some basic number theory puzzles (Vol 2). Djb often refers and quotes the volumes in talks which is one reason why I started reading them, to understand how to hand roll and optimize assembly libraries https://cr.yp.to/talks/2015.04.16/slides-djb-20150416-a4.pdf

There is also the benefits of learning direct programming of hardware, for example MIXAL, used in the first 3 volumes (replaced by MMIXAL) is meant to be run without an operating system. Maybe you want to play around with direct control of a RISC-V chip or fpga or understand the quantum abstract machine Rigetti built and it's instruction language.

bloat 5 years ago

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.

coverclock 5 years ago

Unless you're a computer scientist studying algorithms, probably not. But when I defended my Master's thesis in CS way back in 1983 - yes, I'm that old - my fiancee[1] gave me the three-volume set of Knuth as a graduation gift. I had used his algorithm for arbitrary precision arithmetic in my thesis project. I had figured out addition and subtraction trivially, and had gotten multiplication on my own, but division eluded me. I credit Knuth in part for my being able to graduate with my M.S. Also: my thesis advisor had found a mistake in an earlier edition and was credited in the notes in the back of one of the volumes. So: your mileage may vary. [1] Still married, 35 years at last count.

vbezhenar 5 years ago

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.

xenocratus 5 years ago

There are enough answers about why these kinds of books are not directly relevant to modern software engineering, but are good for putting said discipline in the context of computer science.

That being said, I think you CAN put all that you learn in those books into practice, even if it won't be in your job - try out competitive programming. Try TopCoder or CodeForces, or Google's Code Jam. I think Hackerrank is similar and heavily used for weeding out programmers during the early stages of interviews. As this article states: https://glenmccallum.com/2019/05/14/senior-developers-reject... this sort of "testing" could actually become even more common place for job applications because of how handy it is for recruiters.

But yeah, if you enjoy being competitive in general, consuming books like CLRS or TAOCP and then joining competitions will actually give you a good feel for a programming world very different from the usual, day to day development you'll do at your job.

gcells 5 years ago

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.

timwaagh 5 years ago

It's worth it to have it on your shelf just as a cheap way to remind yourself that you are in fact a real intellectual. Don't read it though, it's barely understandable even with a heavy math background.

  • quickthrower2 5 years ago

    It serves the same purpose as a bible then

sneak 5 years ago

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?

abby_3017 5 years ago

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.

  • jason_slack 5 years ago

    > 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 :-)

bryanrasmussen 5 years ago

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.

vectorEQ 5 years ago

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.

pfortuny 5 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.

knbknb 5 years ago

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.

vinni2 5 years ago

I have been wanting to read them for long. But right now they just look nice in my bookshelf.

jupiter90000 5 years ago

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.

  • bryanrasmussen 5 years ago

    In my experience tedious computer books are published by Packt. TAOP warrants another adjective.

    • jupiter90000 5 years ago

      Tedious: "too long, slow, or dull; tiresome or monotonous." -- TAOP qualifies, for me anyway. Have fun if you like it.

amelius 5 years ago

Just as a remark: I think the volume on searching is in need of an update in this age of search engines.

antoineMoPa 5 years ago

Find it in a library, read some pages. Repeat for Gödel, Escher, Bach.

keithnoizu 5 years ago

Might come up in an interview someday.

  • sohkamyung 5 years ago

    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.

Tepix 5 years ago

You can buy my copy. :-)