Literate programming is Donald Knuth’s term for a method that helps programmers to produce programs that are works of art. In 1984 he explained his choice of the term as follows:
During the 1970s I was coerced like everybody else into adopting the ideas of structured programming, because I couldn’t bear to be found guilty of writing unstructured programs. Now I have a chance to get even. By coining the phrase “literate programming,” I am imposing a moral commitment on everyone who hears the term; surely nobody wants to admit writing an illiterate program.
Literate programming is based on the WEB system of structured documentation. WEB was devised during the development of TEX and METAFONT. It encourages well-structured, well-documented, and well-printed programs and will be familiar to readers of volumes B and D of Computers and typesetting [1,2].
My initial enthusiasm for this book evaporated somewhat as soon as I realized that it consists almost entirely of reprints of previously published papers (all but one written or co-written by Knuth). On rereading the material, however, I decided that a collection of the major papers on literate programming is extremely worthwhile. Whether or not you regard programs as works of art, it is hard to dispute that this book contains one or two classics of computer science.
The book contains 12 chapters. The first three are early works on structured programming. The rest introduce the WEB system, provide examples of its use, and evaluate its effect. The titles of the chapters (with their original dates) are:
Computer Programming as an Art (1974)
Structured Programming with goto Statements (1974)
A Structured Program to Generate All Topological Sorting Arrangements (1974)
Literate Programming (1984)
Programming Pearls: Sampling (1986)
Programming Pearls, Continued: Common Words (1986)
How to Read a WEB (1986)
Excerpts from the Programs for TEX and METAFONT (1986)
Mathematical Writing (1987)
The Errors of TEX (1989)
The Error Log of TEX (1978-1991)
An Example of CWEB (1990)
A new five-page preface, a further reading list, and an index complete the book.