3 ms·
Knuth invented the literate programming methodology and the literate programming tool WEB to write TeX. It is a mistake to say Knuth could ignore all the rules
by jsyedidia 16y ago
Knuth invented the literate programming methodology and the literate programming tool WEB to write TeX. It is a mistake to say Knuth could ignore all the rules in writing TeX because he was a genius. He could ignore the standard methodology because he had a much better one---literate programming.
Knuth attributes his ability to single-handedly write huge bug-free computer programs like TeX, Metafont, the Stanford GraphBase, and the MMIX simulator to literate programming. In his FAQ, he answers the question "What is your favorite programming language?" with CWEB, the literate programming tool that is the descendent of WEB (and was also written using literate programming).
Knuth has been pushing literate programming for a very long time. He wrote a book on the subject ("Literate Programming"), and a book that was full of examples of literate programs (The Stanford GraphBase), as well as his books containing the literate programs for TeX, Metafont, CWEB, and the MMIX simulator. Still most programmers or computer scientists I talk to about it have never heard of literate programming. Given that he's probably the most famous and respected computer scientist in the world, it's quite astonishing. This web-post is another example of ignoring what Knuth himself says about why he can program so well.
- BrandonM 16y agoFrom the Wikipedia article (https://secure.wikimedia.org/wikipedia/en/wiki/Literate_programming https://secure.wikimedia.org/wikipedia/en/wiki/Literate_prog...): The first published literate programming environment was WEB, introduced by Donald Knuth in 1981 for his TeX typesetting system; it uses Pascal as its underlying programming language and TeX for typesetting of the documentation. That is delicious. He programmed in a way that would generate both the documentation for TeX (in TeX) and the source code for TeX (in Pascal). Compiling the source code generates a program that can process that TeX documentation. In other words, the documentation is an integral part of the source code, and the compiled source code is an integral tool in producing the documentation.
- vilhelm_s 16y agoThe talk rjlipton described was from the late 70s though, so it may have predated the idea of literate programming. The quote in primodemus' comment shows that Knuth didn't in fact use the idea of literate programming in his first version of TeX, and he still wrote it in one go on paper ignoring the usual methodology. So maybe "he's a genius" is the right explanation after all.
- jsyedidia 16y agoHe certainly is a genius, and you're right that the first version of TeX was not written using literate programming tools; he planned it out on paper instead and programmed it using SAIL. He had a nasty bootstrapping problem since he needed TeX to exist before he could write a first version of WEB. But once he had a first version of TeX (TeX78), he built WEB, and then he re-wrote TeX from scratch (TeX82) in a different programming language (Pascal/WEB instead of SAIL).