Inweb

The literate programming tool used by Inform

Literate programming is a doctrine for writing programs, or "webs" (no relation to the World Wide one), intended both to be readable by humans and executable by computers. LP had a great influence on the design of Inform 7, and many of its components are themselves webs.

Literate programming was invented by Donald Knuth, who remains its main proponent. He was motivated partly by the need to publish TeX and Metafont in book form - he had been urged to do this by Tony Hoare in the late 1970s, so that students could study non-toy programs (at a time when source code was not much or easily distributed). But Knuth was also motivated by the rise of structured programming and the arrival of Dijkstra and Wirth, by the debacle over Algol standardisation, by his own bookish nature, and by a stubborn scepticism that automated methods would eliminate the need for human attention - ideally, scholarly attention - in programming. The origins of LP go right back to his paper Computer-Drawn Flowcharts (Communications of the ACM 6 (1963), 555-63), even though Knuth chose to reprint this in Selected Papers on Computer Languages (Stanford, 2003) rather than in Literate Programming (Stanford, 1992). Besides TeX-related tools, Knuth has used LP for the Stanford GraphBase, for numerous small algorithmic experiments, and for the MMIX virtual machine. His four big LPs are all available in book form, albeit sadly expensively; all are worth reading.

LP aims to write a program which is as much an argument for its own correctness as it is code. This is done not with logical formalism but with something closer to a demonstration as it might appear in a scientific journal.

Sample of literate program

A key step in literate programming, in our view at least, is publishing. It means tidying up and properly explaining code, and is a process much like writing up roughly-correct ideas for journal publication. The main aim of the Inform project since autumn 2007 has been to publish the whole work. Each web, as it is published, becomes open-source under the Artistic License 2.0, and eventually the whole work will be complete. We believe it will then be the largest literate program ever published.

We appreciate that some of our users would rather have everything open-access even in the scrappiest draft form. A handful of people do send us volcanically angry email about this - open-source fundamentalism is a real force out there - but we hope most people will accept what we're doing as being done in good faith.

As token of our intentions, we'd point out that Inform has produced free open-source software since April 1993 - as a project it belongs to the same generation of early net-spread hacking as Linux (1991) and Apache (1994). The ongoing total rewrite of Inform 7 parallels the 1996 rewrite which produced Inform 6, which has proved a stable and reliable program ever since. We've chosen a licence for published material which is accredited both by the Open Source Initiative and also the Free Software Foundation. Complete recent sources are always available to a dozen or so people and there is nobody whose sudden death by meteorite strike would doom the project. In short, you can safely use it and it will all be all right.

Inweb

When he wound up his short-lived Literate Programming column in CACM (vol. 33, no. 3, 1990), Christopher Wyk made the perceptive criticism of LP that "no one has yet volunteered to write a program using another's system for literate programming". Well, we haven't, either: we use our own inweb, rather than Knuth's CWEB or more modern alternatives like Norman Ramsey's noweb. As a program inweb is not especially interesting; it's both a simplification of CWEB, removing unwanted gadgets and distracting typography, and also an extension, providing for much larger projects with more internal structure, and for languages other than C. But it is essentially CWEB just the same.

Program:Inweb, the literate programming tool used by the Inform project
Maintainer:Graham Nelson (graham@gnelson.demon.co.uk)
Licence:Copyright 2006-2009 by Graham Nelson; published under the Artistic License 2.0
Language:This is itself an inweb project, with the underlying code written in Perl
Published:April 2009.
Version:4/090319.
Browse:All inweb projects have their own self-constructed websites. Here's the one for inweb itself. Newcomers to LP will probably want to read the first few pages of the manual before trying to use inweb.
Download:Here is a gzipped tar of inweb.