The Electronic Labyrinth
HomeContentsTimelineBibliographyIndex

Literate Programming

Donald Knuth has spent many years developing the concept of literate programming. He is best known for the page layout application TEX and the typeface design system METAFONT. The codes for these have been published as full-length books. Why would anyone want to read a book full of code? Perhaps the answer lies in how it is presented. Knuth explains his philosophy succinctly in the preface to Literate Programming:

Programming is best regarded as the process of creating works of literature, which are meant to be read.
Literature of the program genre is performable by machines, but that is not its main purpose. The computer programs that are truly beautiful, useful, and profitable must be readable by people. (ix)

In order to accomplish this goal, Knuth wrote the simple scripting language WEB which acts on an input file in two ways. When "weaving the web," the input file produces documentation; when "tangling the web," program code is produced. Since WEB is responsible for structuring the code as the compiler wishes to see it, the programmer can write down the routines in the order which seems most fitting. Indeed, Knuth argues against the traditional hierarchical arrangement of routines in much the same way as proponents of hypertext argue against strictly linear narratives. He believes that a "stream of consciousness" order is both easier to write and read (126).

The parallels with hypertext go further:

I chose the name WEB partly because it was one of the few three-letter words of English that hadn't already been applied to computers. But as time went on, I've become extremely pleased with the name, because I think that a complex piece of software is, indeed, best regarded as a web that has been delicately pieced together from simple materials. We understand a complicated system by understanding its simple parts, and by understanding the simple relations between the parts and their immediate neighbours. (100)

© 1993-2000 Christopher Keep, Tim McLaughlin, Robin Parmar.
contact us