Literate programming

From XionKB
Jump to navigationJump to search

Literate programming is a programming paradigm introduced in 1984 by the Great Don Knuth in which a computer program is given as an explanation of how it works in a natural language, such as English, interspersed (embedded) with snippets of macros and traditional source code, from which compilable source code can be generated.[1]

The literate programming paradigm, as conceived by Knuth, represents a move away from writing computer programs in the manner and order imposed by the computer, and instead gives programmers macros to develop programs in the order demanded by the logic and flow of their thoughts. Literate programs are written as an exposition of logic in more natural language in which macros are used to hide abstractions and traditional source code, more like the text of an essay.

Conventional literate programming tools are used to obtain two representations from a source file: one understandable by a compiler or interpreter, the "tangled" code, and another for viewing as formatted documentation, which is said to be "woven" from the literate source. While the first generation of literate programming tools were computer language-specific, the later ones are language-agnostic and exist beyond the individual programming languages.

Augmented literate programming

Augmentation is an alternative strategy for making programs literate that works in reverse of the old conventional method of generating multitudes from a single unified set of source code. Instead of the one-to-many approach, a literate programmer takes source code as-is and augments it with documentation using line number oriented references, from which a web page or a paper document equivalent (such as a PDF) can be generated. The main benefit of this approach is far greater comprehension at no loss of structural coherency of code: line groups can be referenced many times, allowing the narrative structure to lead the way in portraying the intention and nuance of a block of code.

Augmented literate programming is the method used in the superwiki concept to achieve literate programming in structural unity with other necessary tools such as version control and the basic task of editing of source text.

References