CSLI Publications logo
new books
knuth books
for authors
CSLI Publications
Facebook CSLI Publications RSS feed
CSLI Publications Newsletter Signup Button
Literate Programming cover

Literate Programming

7th Printing

Donald E. Knuth

Literate programming is a programming methodology that combines a programming language with a documentation language, making programs more robust, more portable, and more easily maintained than programs written only in a high-level language.

Computer programmers already know both kind of languages; they need only learn a few conventions about alternating between languages to create programs that are works of literature. A literate programmer is an essayist who writes programs for humans to understand, instead of primarily writing instructions for machines to follow. When programs are written in the recommended style they can be transformed into documents by a document compiler and into efficient code by an algebraic compiler.

This anthology of essays from the inventor of literate programming includes Knuth's early papers on related topics such as structured programming, as well as the Computer Journal article that launched literate programming itself. Many examples are given, including excerpts from the programs for TEX and METAFONT. The final essay is an example of CWEB, a system for literate programming in C and related languages.

Translated into Japanese.



  • 1. Computer Programming as an Art 1
  • 2. Structured Programming with go to Statements 17
  • 3. A Structured Program to Generate all Topological Sorting Arrangements 91
  • 4. Literate Programming 99
  • 5. Programming Pearls: Sampling 137
  • 6. Programming Pearls, Continued: Common Words 151
  • 7. How to Read a WEB 179
  • 8. Excerpts from the Programs for TEX and METAFONT 185
  • 9. Mathematical Writing 235
  • 10. The Errors of TEX 243
  • 11. The Error Log of TEX 293
  • 12. An Example of CWEB 341
  • 13. Further Reading 349
  • 14. Index 359

ISBN (Paperback): 0937073806 (9780937073803)
ISBN (Electronic): 1575866781 (9781575866789)

Subject: Computer Science; Electronic Digital Computers--Programming

Prof. Knuth's page on this book including table of contents and errata

Add to Cart
View Cart

Check Out

Distributed by the
University of
Chicago Press

pubs @ csli.stanford.edu