Literate Programming

Knuth, Donald E.
Center for the Study of Language and Information
ISBN 0-9370-7380-6
368pp
Date finished: 2004-02-19

I really enjoyed this collection of Knuth's papers about literate programming. His well-known paper "Structured Programming with go-to statements" is included as chapter 2, so I finally got a chance to read the entire thing. His detailed description of literate programming is entertaining and attractive, though for reasons I've described elsewhere I don't think literate programming is worth the effort for many programs.

Probably the most interesting paper in the book is "The Errors of TeX", in which Knuth goes through his error logs and discusses how the TeX implementation was developed and stabilized. Errors are classified in an alphabetical scheme -- "A, an algorithm awry. B, a blunder or botch. ... D, a data structure debacle" and so on -- and I can recognize all of those errors because I've made them too. His testing philosophy is interesting, too: test to destruction with a test suite that exercises extreme cases.

In the second of two included "Programming Pearls" columns, Knuth presents a literate program that reads a text file and outputs a list of the most common words. In his scathing critique of the program, M.D. McIlroy summarizes why Knuthian algorithmic analysis -- highly mathematical, detailed to the point of counting machine instructions-- when he points out that a six-command pipeline of Unix commands can do much the same task, and comments "He has fashioned a sort of industrial-strength Fabergé egg -- intricate, wonderfully worked, refined beyond all ordinary desires, a museum piece from the start." Yes. It would be very nice to be Donald Knuth, able to declare that a program's specification is now frozen and to not use external libraries or data sources that shift and change, but almost no programmers today can be so resolute.

Tagged: computing

Permalink: http://books.amk.ca/2004/02/Literate_Programming.html

%T Literate Programming
%A Knuth, Donald E.
%G ISBN 0-9370-7380-6
%I Center for the Study of Language and Information
%P 368pp
%K computing
%@ 2004-02-19

http://books.amk.ca

Contact me