Literate Programming

by Donald E. Knuth (Stanford, California: Center for the Study of Language and Information, 1992), xvi+368pp.
(CSLI Lecture Notes, no. 27.)
ISBN 0-937073-80-6
Japanese translation by Makoto Arisawa, Bungeiteki Programming (Tokyo: ASCII Corporation, 1994), 463pp.

Literate programming is a methodology that combines a programming language with a documentation language, thereby making programs more robust, more portable, more easily maintained, and arguably more fun to write than programs that are written only in a high-level language. The main idea is to treat a program as a piece of literature, addressed to human beings rather than to a computer. The program is also viewed as a hypertext document, rather like the World Wide Web. (Indeed, I used the word WEB for this purpose long before CERN grabbed it!) This book is an anthology of essays including my early papers on related topics such as structured programming, as well as the article in The Computer Journal that launched Literate Programming itself. The articles have been revised, extended, and brought up to date.

Table of Contents:

  1. Computer programming as an art [P68]
  2. Structured programming with go to statements [P67]
  3. A structured program to generate all topological sorting arrangements [P65]
  4. Literate programming [P109]
  5. Programming pearls: Sampling [Q78]
  6. Programming pearls, continued: Common words [Q79]
  7. How to read a WEB [from TeX: The Program]
  8. Excerpts from the programs for TeX and METAFONT [from Computers & Typesetting, volumes B and D]
  9. Mathematical writing [from Mathematical Writing]
  10. The errors of TeX [P124]
  11. The error log of TeX [P124, with new material]
  12. An example of CWEB [never before published]
  13. Further reading: A comprehensive bibliography of Literate Programming [never before published]

(Numbers like P68 and Q78 in this list refer to the corresponding papers in my list of publications.)

Available from the publisher (CSLI), and also from the distributor (University of Chicago Press).

This book received the Productivity Award from Computer Language magazine, 1992, awarded to products that significantly increase programmer productivity.

Quick introduction to literate programming by Chris Lee

Errata

For a list of corrections to errors in the first printing of this book, you may download either the errata file in plain TeX format (8812 bytes) or the errata file in DVI format (10816 bytes) or the errata file in compressed PostScript format (34478 bytes); the latter files were generated by the TeX file, and last updated 12 Jun 2004. Most of the errors in the first two printings were corrected in the third printing, but several minor errors have been found by sharp-eyed readers of the fourth printing (1998).

page 354, line 8 from the bottom
change 'labrea' to 'ftp.cs'
page 355, line 12
change 'labrea' to 'ftp.cs'
page 362, right column
change 'Nicolass' to 'Nicolaas' in the Habermann entry
page 366, left column
change 'Rustin, Randall' to 'Rustin, Randall Dennis'

I hope the 1998 version is otherwise error-free. But (sigh) it probably isn't. Therefore I will gratefully pay $2.56 to the first person who finds and reports anything that remains technically, historically, typographically, or politically incorrect. Please send suggested corrections to knuth-bug@cs.stanford.edu, or send snail mail to Prof. D. Knuth, Computer Science Department, Gates Building 4B, Stanford University, Stanford, CA 94305-9045 USA. I may not be able to read your message until many months have gone by, because I'm working intensively on The Art of Computer Programming. However, I promise to reply in due time, and to pay your reward with interest compounded from the day you pointed out the error.

DO NOT SEND EMAIL TO KNUTH-BUG EXCEPT TO REPORT ERRORS IN BOOKS! And if you do report an error via email, please do not include attachments of any kind; your message should be readable on brand-X operating systems for all values of X.

Don Knuth's home page

Don Knuth's other books

Valid HTML 4.01 Transitional