# 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.

This book is the first in a series of eight volumes that contain archival forms of my published papers, together with new material.

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.

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.

## 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) or the fifth printing (2008) or the sixth printing (2013):

page xiii, line 8
change 'Eisenstadt' to 'Eisenstat'
page 19, line 11
change '1904' to '1903'
page 39, line 14 from the bottom
change 'Eisenstadt' to 'Eisenstat' (twice)
page 44, line 5
change 'step 1 until' to 'step 1 until'
page 46, line 1
change 'Eisenstadt' to 'Eisenstat'
page 47, line 13 from the bottom
change 'a repeat loop' to 'a repeat loop'
page 57, line 11 from the bottom
change '$n>0$' to '$n\ge0$'
page 58, line 5
change 'average, will' to 'average will'
page 86, line 10
change 'Eisenstadt' to 'Eisenstat'
page 92, line 20
change '$\ne\{x_1,\ldots,x_k\}$ which have' to '$\notin\{x_1,\ldots,x_k}$ that have'
page 159, line 14
add the statement 'count[0] ← 0;' (to agree with page 164)
page 349, lines 9 and 10
change 'Praktis- che' to 'Prak- tische'
page 354, line 8 from the bottom
change 'labrea' to 'ftp.cs'
page 355, line 12
change 'labrea' to 'ftp.cs'
page 358, new item for the bibliography
Klaus Thull, The virtual memory management of PubliC \TeX,'' {\sl TUGboat\/ \bf10},1 (April 1989), 15--22.
page 361, left column
change 'Macdonald' to 'MacDonald' in the Coxeter entry
page 361, left column
change 'x' to 'xii' in the CWEB entry
page 361, right column
change 'Eisenstadt, Stanley C.' to 'Eisenstat, Stanley Charles'
page 362, right column
change 'Nicolass' to 'Nicolaas' in the Habermann entry
page 366, left column
change 'Rustin, Randall' to 'Rustin, Randall Dennis'
page 367, left column
change 'Thull, Klaus, 357.' to 'Thull, Klaus, 358.'
page 368, left column
change '139' to 'xii, 139' in the WEB entry

I hope the 2008 version is otherwise error-free. But (sigh) it probably isn't. Therefore I will gratefully deposit 0x$1.00 ($2.56) to the account of 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. In either case please include your postal address, so that I can mail an official certificate of deposit as a token of thanks for any improvements to which you have contributed.

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.

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.