Le Carnet
Pour la gloire de Dieu et le salut du monde.

Happy Birthday Prof. Knuth

Published on .
by Hubert Behaghel

Donald Ervin Knuth is turning 77 today. He is by far the most fascinating person in the CS world to me. I am going to treat myself and play the total fanboy that I am by telling you my favourite facts about him.

Fact #1: One Book, One Life

Don Knuth, when 24, agrees to write a book about compilers. You know, something straightforward, à la “Compilers in action”: chapter 1 Lexers, chapter 2 Parsers, chapter 3 Generation. And few optimisations techniques in appendice to call it a day. Well, that didn’t work out as expected. Knuth quickly realises there is no proper framework to talk about marginal topics like data structures or algorithms. Remember it’s 1962, early days for our science. That’s all right, Knuth decides that instead of three chapters, he will write seven volumes and the title will now be The Art of Computer Programming. And that will be the undertaking of his life. Six years later in 1968, he publishes …volume 1: Fundamental Algorithms. Last release was in 2005 with volume 4a: Combinatorial Algorithms, Part 1. Expect volume 5 in 2020. I know! He will then be 82 and I am concerned too that we will never know how it ends… At least we know the title of the last volume: Compiler techniques. Still on track.

Fact #2: DIY Typesetting System

In 1977, after the release of the first version of the third volume, Knuth decides that enough is enough: the typesetting system in use by his publisher is frustratingly poor in quality. So he takes a sabbatical and starts writing his own1. One year later, this is the first release of TeX2. What a result! A “labor of love” according to his inventor but also of profound elegance. Speaking of which, Knuth also took the opportunity to invent a language to design vector font: METAFONT. No one will ever measure the magnitude of impact TeX has on today’s world. This becomes the de facto communication tool for ideas in academia. Particularly in Mathematics where it brings a standard and beautiful typography for formulas and equations. This illustrates perfectly one of Knuth’s principles that the very act of communicating one’s work clearly to other people will improve the work itself. We will get back to this later.

On top of TeX, Leslie Lamport would later add his own layer, LaTeX, the now dominant method for using TeX. I wish we had stopped there in terms of word processing in the software industry. If you’re not convinced, look at what you get from any document in Word 2013 and then admire a document produced by TeX82, e.g. The Only Probability Cheatsheet You’ll Ever Need. Don’t get distracted by the equations, feel the joy of your eyes skimming through this pure layout, watch out for those ligatures like in the double f in this off on line 2.

Or here to contemplate the power of those algorithms that optimise hypenation and spacing between words and letters to provide such a beautiful justification.

In TeX, this code:

\begin{align}
    E_0 &= mc^2                              \\
    E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}}
\end{align}

will produce this output:

\begin{align} E_0 &= mc^2 \\
E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}} \end{align}

Fact #3: Literate Programming

Ce que l’on conçoit bien s’énonce clairement,
Et les mots pour le dire arrivent aisément.

Whatever is well conceived is clearly said,
And the words to say it flow with ease.

Boileau, The Art of Poetry (1674)

Ok, so we have mentioned this principle of Knuth’s that communicating one’s work clearly improves the work in itself. We also know of the dogfooding principle whereby using your own solution internally can be of great benefits in terms of design and usability3. What does that mean for TeX? In case you didn’t know, this is called Literate Programming. Knuth indeed coded TeX and METAFONT in TeX or more exactly in WEB. WEB is the first published literate programming environment. As you may have guessed, it was devised by Knuth. It uses TeX for typesetting and Pascal for the coding. In essence, a WEB file is a TeX file that describes and includes a program. With it, you can then tangle the source code ready for compilation and weave the document.

The literate programmer is more of an essayist. It is not totally surprising that it didn’t became mainstream as not all devs resonate with it. Yet TDD is no less radical while being mainstream. Anyways, I like to think it’s gently trending higher and higher. Some languages have native support for it (Haskell with .lhs, CoffeeScript with .litcoffee) and Docco is getting traction from various communities (e.g. Underscore.js, Jasmine to name a few in JS world alone).

It works really well for me. It makes the whole process of thinking, designing, testing and coding natural and pleasant. I use org-mode with org-babel. One day, I’ll have to show you that with a series of screencasts. But if you can’t wait, head over the literate source4 of the presentation featured in a recent post. From that simple file, you get the final presentation and the source code using 4 different programming languages5 which produces the material set included in it. Mind-blowing.

Oh, what a tangled web we weave
When first we practise to deceive!

– Sir Walter Scott, Marmion (1808), Canto VI, XVII

Fact #4: You Can’t Get Geekier

It’s actually a list of facts:

Famous Quotes

Beware of bugs in the above code; I have only proved it correct, not tried it.

Premature optimization is the root of all evil.

Further Reading

Happy Birthday Professor!


  1. Somewhat a similar story to what Linus Torvalds would do 40 years later with git. But it took only 4 days for git to be self-hosted! [return]
  2. In total, the sabbatical would last 10 years to stabilise TeX and METAFONT! I am sure by now you have recognised a pattern in Prof. Knuth’s ways with completeness vs deadlines. [return]
  3. again git comes to mind. GitLab not so much… [return]
  4. if you can’t get access, contact me with your GitHub account and I’ll grant you access. [return]
  5. because why not, it’s called tangling after all. [return]
  6. it’s not your trendy semantic versioning but there is an appeal in a project that as a clear final state in mind. By the way, semantic versioning is a name that I have decidedly filed under what I call pervertonyms. If it sounds like a rant, it’s because it is. I argue that any other meaningful convention on version numbers would have been as semantic as this one. Hence this one doesn’t deserve the name ‘semantic’. It gets utterly baroque when it’s abbreviated semver. I like that it rhymes with whatever. pervertonym (noun): name with an unambiguous, accurate and often scientific definition corrupted into an post-modern usage which is more akin to pop-art than progressive etymology. For examples of pervertonyms, see here and here. [return]