Donald Knuth. “Literate Programming ()” in Literate Programming. CSLI, , pg. I believe that the time is ripe for significantly better documentation of . Literate programming: Knuth is doing it wrong. Literate programming advocates this: Order your code for others to read, not for the compiler. Literate. What is Literate programming? Literate programming is a style of programming invented by Donald Knuth, where the main idea is that a program’s .
|Published (Last):||21 October 2017|
|PDF File Size:||18.51 Mb|
|ePub File Size:||10.42 Mb|
|Price:||Free* [*Free Regsitration Required]|
Quoting from Kernighan and Plauger, ‘Top-down design litfrate successive refinement attack a programming task by progranming it in the most general terms, then expanding these into more and more specific and detailed actions, until the whole program is complete. From Wikipedia, the free encyclopedia. But as time went on, I’ve become extremely pleased with the name, because I think that a complex piece of software is, indeed, best regarded as a web that has been delicately pieced together from simple materials.
The holon integrates with other holons in the hierarchy according to a flexible strategy. Examine source code metrics lines, complexity, etc. The “program” then becomes primarily a document directed at humans, liyerate the code being herded between “code delimiters” from where it can be extracted and shuffled out sideways to the language system by literate programming tools.
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. Applicability of the concept to programming provramming a large scale, that of commercial-grade programs, is proven by an edition of TeX code as a literate program. But then I also progrsmming how much need there was for examples of good-sized programs, that could be considered as reasonable models, not just small programs.
A classic example of literate programming is the literate implementation of the standard Unix wc word counting program. A traditional computer program consists of a text file containing program code.
There are many factors involved in developing excellent software. The first published literate programming environment was WEBintroduced by Donald Knuth in for his TeX typesetting system; it uses Pascal as its underlying programming language and TeX for typesetting of the documentation.
There should be no restrictions on the order in which the program fragments resulting from this decomposition are presented, so that this order can be chosen so as to obtain an optimal exposition; this may even involve bringing together fragments whose location in the actual program is quite unrelated, but which have some logical connection. Numbers lrogramming P68 and Q78 in this list refer to the corresponding papers in my list of publications.
The unraveling of the chunks can be done in any place in the literate program text file, not necessarily in the order they are sequenced in the enclosing chunk, but as is demanded by the logic reflected in the explanatory text that envelops the whole program.
Actually, literate programming uses a method that differs from this only trivially from a formal standpoint, but has a great advantage in practical terms: Parts of the program that belong together logically should appear near to each other in the progrramming, so that they are visible from the part of the documentation that discusses their function.
This concept proceeds from the work of Simon. When the last order of the subroutine has been executed the machine proceeds to execute the order in the program that immediately follows. I am sure that it also helps writers: A preprocessor is used to substitute arbitrary hierarchies, or rather “interconnected ‘webs’ of macros”,  to produce the compilable source code with one command “tangle”and documentation with another “weave”.
The number of lines in a file is The documentation parts of the program description should allow for the same freedom of expression that one would have in an ordinary technical paper. Indeed we believe that deep understanding of a small number of algorithms in this manner provides a stronger base for further study of computer graphics than does a superficial understanding of many.
The typographic tools provided by TeX give us an opportunity to explain the local structure of each part by making that structure visible, and the programming tools provided by languages like C make it possible for us to specify the algorithms formally and unambiguously.
Knuth: Literate Programming
Comment source code effectively with header and in-line comments. Let us change our traditional attitude to the construction of programs: Literate programming was first introduced by Donald E. Errata For a list of corrections to errors in the first printing of this book, you may download either the errata file in plain TeX format literatw or the errata file in DVI format bytes or the errata file in compressed PostScript format bytes ; the latter files were generated by the TeX file, and last updated literxte Jun It is designed so that when its task is finished it returns control programminv the master routine at a point immediately following that from which it was called in.
To document such a program we want to explain each individual part of the web and how it relates to its neighbors.
Such exposition of ideas creates the flow of thought that is like a literary work. The documentation portion is often a verbal description of the algorithm. Actually, writing out the expanded source code can be done from any section or subsection i. While it is not.
It is the difference between performing and exposing a magic trick. Literacy in programming means different things in different circumstances. KnuthLiterate Programming . Neither type of language can provide the best documentation by itself; but when both are appropriately combined, we obtain a system that is much more useful than kiterate language separately.
The same example was later rewritten for the noweb literate programming tool.