28 ms·
For Donald Knuth, good coding is synonymous with beautiful expression
- ScannerSparkly 7y agoHas anyone read his books? Seems like an interesting way to get into programming. I enjoy reading, but I never thought that a book about programming would present it's ideas and technical details through stories.
- dctaflin 7y agoI used his books as a way to learn the things about computer science that I missed out on by not having a CSci degree. They are very mathematical, but that's just a bonus for me. They are certainly not light reading.
- commandlinefan 7y ago> I missed out on by not having a CSci degree I have a BS & MS in CS, and most of the material in TAOCP was still new to me. Even the stuff I thought I knew like hash functions was covered in a new depth I never would have imagined.
- sasaf5 7y agoI often consult the "Seminumerical Algorithms" volume, as someone who has to implement lots of digital arithmetic. It is wonderful to help me base my choice of algorithms on math. I wouldn't recommend it as a way to get into programming though, as it is more about algorithms than about how to code them in a practical language. Perhaps his books on literate programming would be better for this purpose.
- pbourke 7y ago> Seems like an interesting way to get into programming. This would be an iconoclastic route into programming, to say the least. If you are looking for a more approachable or practical book that gets you programming and introduces some theory I recommend “Classic Computer Science Problems in Python” by David Kopec. Reading TAOCP to get into programming is sort of like reading a physics textbook in order to build a doghouse in your backyard.
- dhosek 7y agoMy first major programs were written under the influence of Knuth—I spent a lot of time reading the source code of TeX and its related programs and learned a lot from that. In fact, I only ever took one computer science class in my life (I went three times and got a C), so I'd have to say that Knuth was by far the most formative influence on my early programming. The other day I was actually looking to see if there was any trace of the DVI previewer I wrote for VM/CMS back in the 80s around on the internet. As near as I can tell, there is not. It'd probably be embarrassing to see (among other things, I didn't do any caching of font bitmaps, mostly because I didn't know how and didn't have time to learn, so every character displayed on screen re-read the bitmap data from disk).
- kragen 7y agoHow do you get pixels on a screen from VM/CMS?
- dhosek 7y agoThere were two graphic output options in the previewer. There were specialized graphic terminals using the GDDM protocol (this code was actually written by someone in Germany who sent me their changes). The original code that I wrote used Tektronics graphics protocols available in the terminal driver that connected to the mainframe via a protocol converter that enabled the use of cheap ASCII terminals instead of the standard dedicated IBM terminals.
- kragen 7y agoOh man, you were drawing pixel fonts on a 4014 storage tube? That must have taken forever.
- dhosek 7y agoIt was an emulation of it on a PC. VT100+Tektronix was a common graphics option on terminals of the era and the PC terminal software provided that as its graphics choice. I had some optimizations like replacing any characters below a certain threshold size with a solid box based on the bitmap's bounding box. It was reasonably fast given the speed of the connection.
- pgtan 7y agoI try to implement in Emacs Lisp Knuth's combinatorial algorithms from https://www-cs-faculty.stanford.edu/~knuth/fasc2b.ps.gz https://www-cs-faculty.stanford.edu/~knuth/fasc2b.ps.gz I just managed to finish the first Alg. P (plain changes); it was really hard, considering that I didn't understand the algorithm and the description is made for Pascal like languages.
- carapace 7y agoHe wrote a love story about Surreal numbers. I haven't read it yet but it's on my list FWIW.
- kragen 7y agoI think it's potentially dangerous. When I was first learning to program, there were a lot of things I couldn't figure out how to do. Then I came across an algorithms textbook (Algorithms in C, by Knuth's student Sedgewick) and it explained how to do a lot of things I had never been able to figure out how to do before, and with beautiful code. This was a wonderful revelation! I then spent a lot of time studying algorithms. Unfortunately, I didn't learn how to program! I thought that what I was missing was knowledge about algorithms, and that was occasionally right but mostly wrong. Worse, algorithmic textbooks bias you to look for the one weird trick that makes your apparently complex problem simple. But usually that trick doesn't exist, and when it does you usually have to solve the problem the hard way first before you understand the problem well enough to find it. The process of debugging, refactoring, optimizing, and testing that gives rise to the final polished form of a program cannot easily be inferred from what remains. Books like The Practice of Programming and Code Complete were much more helpful, but you can't learn to program by reading books, any more than you can learn to play baseball or win lawsuits by reading books. I did eventually learn to program pretty well, though I'm not yet a master of the craft like Knuth, Jeff Dean, Rob Pike, Walter Bright, or Norvig. I did it largely by a practice described in this interview: writing new programs every day. I also learned a lot from pair-programming, which taught me both to read other people's code (we had collective code ownership) and to write code others could understand. My main obstacle was not ignorance but perfectionism and lack of practice.
- bitwize 7y agoPeople often say "TAOCP is a dense, technical book, you don't just sit down and read it cover to cover." It is dense and it is technical, but it's also a joy to sit down and read and this is why. Knuth doesn't present an algorithm and annotate it with (Foobar 1968) and that's that. He says "Bazquux came up with an early version of this algorithm in 1962 while working on missile trajectories for the Department of Defense, then Foobar came up with the linear-time optimization that we all use today." Stuff like that.
- pmiller2 7y agoI agree that Knuth's exposition is a joy to read, and there are a lot of significant mathematical insights to be had within those volumes. I just wish he could get away from MIX/MMIX. I don't find it very useful or interesting as a pseudocode, and I think it gets in the way of understanding.
- 0x8BADF00D 7y agoYeah that’s actually what I found intimidating about TAOCP when I was in undergrad. But I stuck with it, and it was a genuinely good read. I feel like SICP is a better introductory text, though.
- ska 7y agoTAOCP was never intended to be an introductory text, so that's unsurprising.
- kragen 7y agoOn the contrary, I think it's extremely useful to have the algorithms realized in a form that has a cost model free of handwaving. The books are to a great extent focused on computational costs, and high-level languages obscure those costs. The only exception is that the books only rarely dive into the variable computational costs due to operating on values of different sizes; heapsort, for example, is only O(N log N) time if comparisons take constant time, while, in fact, as key cardinality approaches infinity, key size grows as O(log N). (Which is why O(N) time sorting is possible.) This kind of thing is growing more important as hardware design becomes more accessible; there are probably more people writing VHDL and Verilog now than were writing any kind of software when Volume 1 came out. So I think using a high-level language would get in the way of understanding those costs, and even to some extent how to implement the algorithm in other contexts. If you just want to implement a red-black tree or something, then sure, the MMIX code isn't going to help you. But he also presents all the algorithms in pseudocode, so you can use that.
- plg 7y agoI like this: "A person’s success in life is determined by having a high minimum, not a high maximum. If you can do something really well but there are other things at which you’re failing, the latter will hold you back. But if almost everything you do is up there, then you’ve got a good life."
- larntz 7y agoThis is interesting and very true. It reminds me of people who are excellent at something but their life gets held back by alcohol/drugs or bad relationships or some other _low minimum_. That first sentence is really profound in my opinion.
- barrkel 7y agoYou've never experienced good art by a tortured artist, then?
- alfonsodev 7y agoThat would be success in art but failing in life, by the quote definition, I infer he’s equating success in life with your minimum quality of life indicators being as high as posible, if I got it right.
- larntz 7y agoThat's how I read it also. Take for example Kurt Cobain (whatever you think of him and his music). He had major success in music, but his life was a disaster and not something I'd hope for a loved one. I do agree that it seems like the best art is created by "tortured artists".
- barrkel 7y agoDo you think he'd be ok with the opposite - a bland, contained and long life? What is life for? There are fundamental questions here and I don't think the answers are obvious as you seem to think.
- plg 7y agoMan for an older person he is using a really small font on his screen! Also: looks like a GNU/Linux variant not windows or macOS.
- sasaf5 7y agoTrue. The editor on the left side does look like emacs.
- alxlaz 7y agoThat's the FVWM window manager. His FVWM config (or at least some version of it) is available if you're curious: https://www-cs-faculty.stanford.edu/~knuth/programs/.fvwm2rc https://www-cs-faculty.stanford.edu/~knuth/programs/.fvwm2rc .
- sasaf5 7y agoThanks so much for this link! It also explains what I am seeing in that picture: "Now comes the fun part: Buttons to push that will take me from one desktop to another. Being a control freak, I am not trusting FvwmButtons to find the correct button layout; I'm building it myself. The goal is to have a 64x64 ASClock at the upper right, preceded by four 32x32 buttons that will aim my display at another desktop, all above a 16x128 CPU load display. Geometry-wise, I consider it to be an 8x5 grid of 16x16 squares (although I could have regarded it as a 4x5 grid of 32x16s)."
- ISL 7y agoThat's the most-pleasant .rc file I've ever read.
- lepasana 7y agoThank you for this.. When I see the picture in the article, I was wondering what kind of editor he is using
- smabie 7y agoMan, he's really bought in to that whole literate programming thing..
- smitty1e 7y agoThere is a joy that shines through everything Knuth does. Those who have ears hear the reason for this.
- markarranz 7y ago> I write an average of five new programs every week. Poets have to write poems. I have to write computer programs. It seems more obvious now that I read it. A lot of programmers out there, including myself, are looking for ways to improve their skills and I never thought to myself to write more programs. And not just programs for the sake of programs, but programs that force you to explain to the computer that you understand certain concepts. This man is and will continue to be a huge inspiration.
- Kenji 7y agoIsn't it obvious that practicing your art is a prerequisite for improving your skills?
- deleted 7y ago[deleted]
- snazz 7y agoAs obvious as it seems, the advice really does apply to everything. I'm okay starting a bunch of projects and never finishing them, because I'm always learning something. When I do start a new project, I usually try ten or so different programming languages and environments to see which one is a good fit for the project. That said, there's certainly something to be said for finishing projects that you're proud of and getting to know one toolchain very well. A mix of both is good.
- 2OEH8eoCRo0 7y ago>The ceramics teacher announced on opening day that he was dividing the class into two groups. All those on the left side of the studio, he said, would be graded solely on the quantity of work they produced, all those on the right solely on its quality. His procedure was simple: on the final day of class he would bring in his bathroom scales and weigh the work of the "quantity" group: fifty pound of pots rated an "A", forty pounds a "B", and so on. Those being graded on "quality", however, needed to produce only one pot - albeit a perfect one - to get an "A". Well, came grading time and a curious fact emerged: the works of highest quality were all produced by the group being graded for quantity. It seems that while the "quantity" group was busily churning out piles of work - and learning from their mistakes - the "quality" group had sat theorizing about perfection, and in the end had little more to show for their efforts than grandiose theories and a pile of dead clay.
- mkchoi212 7y agoSo much respect for the man. Hope he stays safe during these times and lives long enough to finish the series :D
- mkchoi212 7y agoI feel like when people start talking about TAOCP, the first thing that comes up is the fact that you need to know a good amount of math to understand Knuth's language. But what people are forgetting is the fact that his books are just bunch of stories told in mathematical language. You need just the slightest of math knowledge to be able to follow his stories. Maybe hard in the beginning - because yes, it's dense - but once you get used to his way of storytelling, you get hooked.
- kragen 7y agoA thing I never knew before: Donald Knuth, the paragon of scholarship and of a life well spent, not only cleans his own toilets but bought a specific janitorial uniform to make the process more efficient. I find this inspiring enough that I am going to clean my toilet now.
- 7thaccount 7y agoWho else would clean his toilets? Is he wealthy? I assumed no.
- gmfawcett 7y agoWealthy enough to have a pipe organ in his home on the Stanford campus! I'm sure he could afford a housekeeper if he wanted one.
- kragen 7y agoYes, that's how he was able to build his house around a custom-built pipe organ. Also, though, many men of his generation leave the toilet-cleaning up to their wives. But he says he and Jill each have uniforms for this purpose. (My toilet looks and smells much better now.)
- 7thaccount 7y agoMakes a bit more sense.
- rndgermandude 7y agoTAOCP sold more than 1 million copies over the years. Which doesn't make him Zuckerberg rich but wealthy enough to afford a house keeper if he wanted.
- kragen 7y agoI haven't asked him but I don't think his book earnings are significant compared to his salary and pension.
- lordleft 7y agoDonald Knuth manages to be brilliant, well-read and also just a nice person. Sort of refreshing given our field's tendency to let mean-spirited people off the hook if they happen to be good at what they do.
- tartoran 7y agoEven here on HN I've seen quite a bit of criticism of Donald Knuth alluding that somehow he's become irrelevant. Personally I appreciate Donald Knuth the scientist as well as Donald Knuth the person. Mean spirited people will get better at what they do but will probably miss the mark on becoming a great and humble person such as Donald Knuth. I'm really grateful that he's still among us and still working on his his books and that he shares his wisdom with us.
- senthil_rajasek 7y agoWhenever people bring up aesthetics in coding they forget to balance it. Here is the man himself on how he feels about code aesthetics, “I do think issues of style do come through and make certain programs a genuine pleasure to read. Probably not, however, to the extent that they would give me any transcendental emotions.” [1] [1] Knuth, D. E. Things a Computer Scientist Rarely Talks About. Center for the Study of Language and Information, Stanford, California. 2001.
- third_I 7y agoAs Paul Dirac so eloquently put, > “I think that there is a moral to this story, namely that it is more important to have beauty in one's equations that to have them fit experiment. If Schrödinger had been more confident of his work, he could have published it some months earlier, and he could have published a more accurate equation. It seems that if one is working from the point of view of getting beauty in one's equations, and if one has really a sound insight, one is on a sure line of progress. If there is not complete agreement between the results of one's work and experiment, one should not allow oneself to be too discouraged, because the discrepancy may well be due to minor features that are not properly taken into account and that will get cleared up with further development of the theory.” > Scientific American, May 1963. By that token, coding should be beautiful first, in elegance of structure and forms. And then we can iron out the bugs. I tend to agree.
- typon 7y agoIsn't this line of thinking which has held physics back for the past few decades? I thought that physics is gradually moving to being more data driven than being driven by ideas of beauty. Sabine Hossenfelder has written quite a bit about this.
- third_I 7y agoThe problem with theoretical physics, in my external perception, is more political, within academia. - selecting for the H index, that is, what will be most cited, leading to strong convergence around "consensual" or "popular" research, at a huge detriment to diversity of ideas - one negative effect is a major push for incremental publication (equivalent of a LOC KPI for coders... it's just wrong). “What did you publish this year? How many times was your name in a paper somewhere?” - putting funds and institutional support behind people you like as opposed to people with the most promising ideas. That's pretty much the story of string theory, and see how despite the failure they are still "winning" politically, occupying top positions and feeding the mainstream vulgarization, whereas those who "lost" decades ago are still AWOL even as their ideas are freshened up by a new generation, whose future against the institutional pyramid is all but guaranteed. We might still be there (a situation of total stagnation, since the 1970s, at the theoretical level) by 2040 if something doesn't change profoundly in the way university politics have such a compelling handle on research, thus on our progress in science in general. My 2cts but I'm parroting, people who now speak up in academia. What I do know about, ML, is all but dead currently in MIT, Stanford, etc. It's just monkey coding applying whatever the industry likes for short-term benefits (again this "incremental"-only approach, playing it safe with 0.001% gains that are, sure, predictably doable). There's no actual research on "AI" let alone the general notion of "intelligence". Not even in neuro. I fear we've lost sight of the importance of basic research, as basic as it gets in a given field, because industry deals run the show in terms of funding. Yet look what Bell Labs or MIT did in the 1970-80s, surfing on the last wave of fundamental breakthroughs of the 50-60s. These days are long gone.
- wglb 7y agoAn interesting book interviewing high-level programmers is https://en.wikipedia.org/wiki/Coders_at_work https://en.wikipedia.org/wiki/Coders_at_work. The book starts out with JWZ and ends with Knuth. In addition to covering their work, Peter also asks each one whether or not they have read TaoCP, how they feel about C++, and whether the use a debugger. Only one of the people has read the book, with even Knuth saying that he hasn't read it. Of course, he is joking. But this is a fun read.
- pkhamre 7y agoI tend to be a good writer and able to express specific feelings easily. Should I learn to code?
- RMPR 7y agoCoding is a valuable skill for everyone, not only computer scientist, a popular recommendation of mine for those who want to learn what it looks like while having a decent introduction is: Automate The Boring Stuff With Python https://nostarch.com/automatestuff2 https://nostarch.com/automatestuff2
- thsealienbstrds 7y agoKnuth invented a system that combines writing and coding: literate programming. Maybe you'd like that.
- ssivark 7y agoHere’s the funny thing... If Knuth (or a modern avatar) were applying for a faculty position today, or coming up for tenure, would s/he succeed?
- m23khan 7y agoDonald Knuth and Larry Wall - I find these guys in the field of Computer Science the most intriguing.
- Tomis02 7y ago> Science is much easier to learn if you know the sequence of discoveries. Is there a math book that gives the historical context (what is the exact problem this piece of math is trying to solve)?
- philiplu 7y agoI learned programming from TAOCP, but that was in the mid-70s, when good expository texts were rarer. I mostly skipped over the math then, and tried to figure out the algorithms. Actually wrote a MIX assembler/simulator, which taught me a ton of low-level programming. If you're into the math side of this, I'd highly recommend the book "Concrete Mathematics", which Knuth wrote with Graham and Patashnik. I got it to get better at solving problems over at Project Euler, but it's a fun read, like TAOCP. As deep as it is, it's amazingly light-hearted, down to the graffiti in the margins from the students who proof-tested the material in a Stanford course.
- galaxyLogic 7y agoI think a point is that when you create software there are so many choices how you could create a given piece of program. Trying to figure the best way to do it before you actually do it could take very long, and you still would not be very much wiser because it would all be in your head not in software. Whereas if you just do it you have something you can learn from, and make incrementally better
- knolax 7y agoHow does that gel with TeX, whose syntax creates expressions that are nearly universally regarded as ugly?
- legedemon 7y agoDoes someone know which are the books lying on his bookshelf? Alternatively, is there an interview with Donald Knuth where he mentions the books he studies.