Literate Programming Essentials

Literate Programming (LP) is a programming style for developing programs and their documentation. In this style a program is primarily seen as a document that explains a problem solution to a human reader.

This view is radically different from the widely accepted view of a program as a list of instructions to a computer to solve a problem. In the latter view, human understanding is, to a lesser or greater extent, treated as a sort of secondary issue. Knuth [1984] maintains that, if applied correctly, LP leads to the development of better programs which are more elegant, effective, transportable and understandable. The maintenance and amendment of such programs will also be eased. The essentials of LP may be summarised as follows:

# Literate Quality

The completed program is a literate work of art that explains to the reader what the computer is supposed to do. A program, as seen by the computer, is a set of components combined in some structure. The literate programmer can be regarded as an essayist that explains the solution to a human by crisply defining the components and delicately weaving them together into a complete artistic creation [Knuth, 1984]. Lee [1994] goes so far as to describe a literate program as a publishable-quality document that argues mathematically for its own correctness. However most practitioners would not insist on such a level of formality.

NB. One of the practitioners who does is Konrad Hinsen with his Leibniz notation.

> My aim with Leibniz is to introduce a variant. Technically speaking it could be called "literate specifications" (though that's not a good term for its intended audience, hence my term "Digital Scientific Notation"). I believe that specifications are a better support for communicating software behavior to humans than fully fleshed out source code with all its technical details.

Konrad Hinsen via mastodon

[…]

~

PIETERSE, Vreda, KOURIE, Derrick G. and BOAKE, Andrew, 2004. A case for contemporary literate programming. In: ACM International Conference Proceeding Series. Online. 2004. p. 2–9. pdf .

See also "What is the difference between Moldable Development and ... --- literate programming" gt book

> They are similar in that they both promote the use of narratives for depicting systems. However, literate programming offers exactly a single narrative, and that narrative is tied to the definition of the code. Through moldable development we recognize that we always need multiple narratives, and that those narratives must be able to address any part of the system (not only static code).