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):||17 December 2017|
|PDF File Size:||18.64 Mb|
|ePub File Size:||17.31 Mb|
|Price:||Free* [*Free Regsitration Required]|
Literate Programming in WEB”. The typographic processing of literate programs produces code listings with elegantly formatted documentation and source code. The fundamental elements of any computer program are, perhaps not surprisingly, time and space. Anything that is logically part of the section should be moved into it, thereby reducing the complexity of the code where it is referenced.
Then when I started writing TeX in this period I began the implementation of TeX in October ofand I finished it in May 78it was consciously done with structured programming ideas. Literate programming is very often misunderstood  to refer only to formatted documentation produced from a common file with both source code and comments — which is properly called documentation generation — or to voluminous commentaries included with code.
The present chunkwhich does the countingwas actually one of the simplest to write. If we made these variables local to main, we would have to do this initialization explicitly; however, C globals are automatically zeroed. Again, I did this in the interests of simplicity, because I noticed that most applications of multiple parameters could in fact be reduced to the one-parameter case. Establish structures, processes, and outcomes see Luke Holman.
The whole concept of code sections, indeed structured programming, is to reduce the amount of text that must be read in order to determine what a piece of code is doing. This concept proceeds from the work of Simon.
Now, he says, take my large program and reveal it to the liteeate, with all its compromises. I use the following list of requirements to imply a definition of a literate program and the minimum set of tools which are needed to prepare, use, and study the resulting code.
This approach was implemented at Stanford University as a part of research on algorithms and digital programmimg. This book is the first in a series of eight volumes that contain archival forms of my published papers, together with new material.
The documentation and high-level language code are complementary and should address the same elements of the algorithms being written. Literate programming is just a single technique to be used along with all the other well established software engineering practices. In other words, the name of one macro can usefully be a parameter to another macro.
This book is an anthology of essays including my early papers on related topics such as structured programming, as well as the article in The Computer Journal that launched Literate Programming itself. From the programming language point of view the most obvious method of identification would be to use identifiers, resulting in a simple system of parameter-less macros, with as only unusual aspect that uses of the macro are allowed to precede the definition, and indeed do so more often than not.
The same example was later rewritten for the noweb literate programming tool. Program comprehension is a key activity during corrective and perfective maintenance.
The articles have been revised, extended, and brought up to date. However, because these tools do not implement the “web of abstract concepts” hiding behind the system of natural-language macros, or provide an ability to change the order of the source code from a machine-imposed sequence to one convenient to the human mind, they cannot properly be called literate programming tools in the sense intended by Knuth.
Literate programming: Knuth is doing it wrong
If Microsoft had made source files XML, tens of thousands of programmers would already be putting pictures and hyperlinks in their code. Develop small classes and small functions when feasible. Hoare had heard rumors about my work and he wrote to Stanford suggesting that I keep publication in mind. Literate programming Computer-related introductions in The program description should describe parts of the algorithm as they occur in the design process, rather than in the completed program text.
It should be an unusual but not exceptional case when a module contains no documentation. This differs from traditional documentation, in which a programmer is presented with source code that follows a compiler-imposed order, and must decipher the thought process behind the program from the code and its associated comments. There are various other implementations of the literate programming concept some of them don’t have macros and hence violate the order of human logic principle:.
The key features of literate programming are the organization of source code into small sections and the production of a book quality program listing. The high-level language code and the system documentation of the program come from the same set of source files.
This means that the document describing the program should consist of formatted text, rather than being a plain text file. Actually, writing out the expanded source code can be done from any section or subsection i. While it is not.
Hanson’s real-world code, then, must be evaluated according to whether it is robust, flexible, and easy to maintain. Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
If programs are written in a way that concentrates on explaining their design to human readers, then they can be considered as works of technical literature; it is for this reason that Knuth has named this style of software construction and description “literate programming”. Many programming environments are completely controlled by specific vendors, who may well choose to switch from flat text to rich markup for their own reasons.
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. But Knuth is concerned not only with bytes and microseconds, but with a concept that has come to be known in coding circles as “elegance,” and that applies to programming at any level.
Applicability of the concept to programming on a large scale, that of commercial-grade programs, is proven by an edition of TeX code as a literate program.