Literate programming

Literate Programming by Donald Knuth is the seminal book on literate programming.

Literate programming is a programming paradigm introduced in 1984 by Donald 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 approach is used in scientific computing and in data science routinely for reproducible research and open access purposes.[2] Literate programming tools are used by millions of programmers today.[3]

The literate programming paradigm, as conceived by Donald Knuth, represents a move away from writing computer programs in the manner and order imposed by the compiler, and instead gives programmers macros to develop programs in the order demanded by the logic and flow of their thoughts.[4] 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.

Literate programming (LP) 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.[5] 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.

  1. ^ v w x y z Knuth, Donald E. (1984). "Literate Programming" (PDF). The Computer Journal. 27 (2). British Computer Society: 97–111. doi:10.1093/comjnl/27.2.97. Retrieved January 4, 2009.
  2. ^ Schulte, Eric (2012). "A Multi-Language Computing Environment for Literate Programming and Reproducible Research" (PDF). Journal of Statistical Software. 46 (3). doi:10.18637/jss.v046.i03. Archived (PDF) from the original on 9 November 2014. Retrieved 30 May 2020.
  3. ^ Kery, Mary Beth (April 2018). "The Story in the Notebook: Exploratory Data Science using a Literate Programming Tool". CHI '18: Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems. ACM. pp. 1–11. doi:10.1145/3173574.3173748.
  4. ^ "I had the feeling that top-down and bottom-up were opposing methodologies: one more suitable for program exposition and the other more suitable for program creation. But after gaining experience with WEB, I have come to realize that there is no need to choose once and for all between top-down and bottom-up, because a program is best thought of as a web instead of a tree. A hierarchical structure is present, but the most important thing about a program is its structural relationships. A complex piece of software consists of simple parts and simple relations between those parts; the programmer's task is to state those parts and those relationships, in whatever order is best for human comprehension not in some rigidly determined order like top-down or bottom-up." — Donald E. Knuth, Literate Programming[1]
  5. ^ If one remembers that the first version of the tool was called WEB, the amusing literary reference hidden by Knuth in these names becomes obvious: "Oh, what a tangled web we weave when first we practise to deceive" – Sir Walter Scott, in Canto VI, Stanza 17 of Marmion (1808) an epic poem about the Battle of Flodden in 1513. – the actual citation appeared as an epigraph in a May 1986 article by Jon Bentley and Donald Knuth in one of the classical Programming Pearls columns in Communications of the ACM, vol 29 num 5 on p.365

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search