Literate Programming

by Donald E. Knuth

CSLI Lecture Notes (27)

On This Page

Description

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 kinds 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 show more 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. show less

Tags

Recommendations

Member Reviews

3 reviews
Like any of Donald Knuth’s books, this work constitutes a classic of computer science. Knuth attempts to integrate the art of writing good literature with the art of writing computer code. Using a series of papers and articles published between 1974 and 1989, he illustrates the historical genesis of writing more understandable code. Although modern programmers will find many constructs to be dated, the historical and conceptual value of these writings cannot be underestimated. Without such understanding of the past, modern programmers will merely spin their wheels in older problems instead of inventing the future.

This work starts out with an old debate (1970s) on the “goto” statement’s use. The conclusion Knuth reaches is the show more conclusion the rest of the community ended up maintaining – that the goto statement obscures rather than clarifies readable code. It’s interesting to see, even if just at a scanning glance, how ideas come together in one context and inspire further conversation in later contexts (i.e., the rest of the book). This introduction, though lengthy, climaxes in an important question: What exactly is readable code?

The author develops a system called WEB to address this problem. WEB combines markup text in the TEX markup language with Pascal code. As such, each approach is described twice in code, once in human language and another in computer language. This provides obvious benefit to programmers seeking to maintain code – a challenge far more difficult in today’s context thirty years hence. Although present-day languages are different, many approaches still use the basic kernel of this book’s ideas by combining coding and documentation (e.g., JavaDoc and PHPDoc). These are more than comments; they are systematic documentation for a pre-processor to parse and produce compiled, printable literature.

Obviously, this work is a historical gem to those interested in the history of computing. Advanced programmers and those interested in the theoretical and historical underpinnings of modern technologies will be most interested. Even those working with programmers might find some benefit. Studying the thought processes behind innovation is a helpful process for speeding modern development. This is a really good case study in such approaches over 16 years of written conversations.

Beginning and even intermediate programmers may not be interested in this work as much as I am. However, such programmers should still familiarize themselves with the author’s name Donald Knuth. He is perhaps the greatest founder of computer programming. At the time of my writing (2021), he is still alive. He helped with several advances, including the LaTEX markup language, which is partially described in this book. Literate Programming is often described as a fourth work added to Knuth’s trilogy (his magnum opus) on computer algorithms. It’s always fun and beneficial for me to wrestle with good minds; this book provides plenty of fodder for that.
show less
At one point, I wrote C++ code using CWEB. The experience (which I found rather positive) convinced me that almost no other developer I knew would find it positive. (The approach of writing discursive text and code in parallel, although highly conducive to good code, is also extremely demanding.)

This collection of papers, centred on WEB and on related issues -- the article on "The Errors of TeX" should be required reading in any CS course of study -- remains both enlightening and relevant thirty-plus years on, although the overall approaches of most software practitioners (IDEs, automated refactoring tools, etc.) make the application of the disciplines described less likely than ever.
A very specialized book, but outstanding within that small area. This is a collection of essays and information on Literate Programming, and includes some of the seminal articles on the subject by Dr. Knuth, including a reprint of the first published article on literate programming . It also includes some other discussion of computer programming styles, although I would not recommend the book solely for that subject matter.

In short, if you're not interested in literate programming, then you probably won't find this worthwhile. If you are interested in the subject, this is a must have book.

Members

Recently Added By

Author Information

Picture of author.
Author
81 Works 9,674 Members
Donald E. Knuth is known throughout the world for his pioneering work on algorithms and programming techniques, for his invention of the TEX and METAFONT systems for computer typesetting, and for his prolific and influential writing. Professor Emeritus of The Art of Computer Programming at Stanford University, he currently devotes full time to the show more completion of these fascicles and the seven volumes to which they belong. show less

Series

Belongs to Publisher Series

Common Knowledge

Canonical title
Literate Programming
Original publication date
1992

Classifications

Genres
Technology, Nonfiction
DDC/MDS
005.11Computer science, information & general worksComputer science, knowledge & systemsArtificial Intelligence/Virtual RealitySoftware developmentSoftware development methods; programming paradigms
LCC
QA76.6 .K644ScienceMathematicsMathematicsInstruments and machinesCalculating machinesElectronic computers. Computer science
BISAC

Statistics

Members
218
Popularity
150,122
Reviews
3
Rating
(3.83)
Languages
English
Media
Paper
ISBNs
2