Literate programming

related topics
{math, number, function}
{system, computer, user}
{theory, work, human}
{language, word, form}
{work, book, publish}
{style, bgcolor, rowspan}

Literate programming is an approach to programming introduced by Donald Knuth as an alternative to the structured programming paradigm of the 1970s.[1]

The literate programming paradigm, as conceived by Knuth, represents a move away from writing programs in the manner and order imposed by the computer, and instead enables programmers to develop programs in the order demanded by the logic and flow of their thoughts.[2] Literate programs are written as an uninterrupted exposition of logic in an ordinary human language, much like the text of an essay, in which macros which hide abstractions and traditional source code are included. Literate programming tools are used to obtain two representations from a literate source file: one suitable for further compilation or execution by a computer, the "tangled" code, and another for viewing as formatted documentation, which is said to be "woven" from the literate source.[3] While the first generation of literate programming tools were computer language-specific, the later ones are language-agnostic and exist above the programming languages.

Contents

Concept

A literate program is an explanation of the program logic in a natural language, such as English, interspersed with snippets of macros and traditional source code. Macros in a literate source file are simply title-like or explanatory phrases in a human language that describe human abstractions created while solving the programming problem, and hiding chunks of code or lower-level macros. These macros are similar to the algorithms in pseudocode typically used in teaching computer science. These arbitrary explanatory phrases become precise new operators, created on the fly by the programmer, forming a meta-language on top of the underlying programming language.

A preprocessor is used to substitute arbitrary hierarchies, or rather "interconnected 'webs' of macros",[4] to produce the compilable source code with one command ("tangle"), and documentation with another ("weave"). The preprocessor also provides an ability to write out the content of the macros and to add to already created macros in any place in the text of the literate program source file, thereby disposing of the need to keep in mind the restrictions imposed by traditional programming languages or to interrupt the flow of thought.

Advantages

Full article ▸

related documents
ActiveX Data Objects
XML-RPC
Flyweight pattern
Java Naming and Directory Interface
8.3 filename
Specification language
Kvikkalkul
Curl (programming language)
Bookmarklet
Class (set theory)
SNOBOL
Cipher
Connectedness
Elias gamma coding
Earley parser
Euler's identity
Data type
Parse tree
Unitary matrix
AIML
Unit interval
Linear function
Inner automorphism
Regular graph
Disjunctive normal form
Subring
Profinite group
Inverse transform sampling
Discrete probability distribution
Urysohn's lemma