next up previous contents
Next: 1.4 How to read Up: 1. Introduction Previous: 1.2.3 D-TLBs. Distributed Memory

   
1.3 Literate programming

As this document is hardcopy of a literate program [#!knuth92:_litprog!#] we think that it is worth saying something about this technique. We do it by citing the comp.programming.literate newsgroup FAQ:

``Literate programming is the combination of documentation and source together in a fashion suited for reading by human beings. In fact, literate programs should be enjoyable reading, even inviting! [...] In general, literate programs combine source and documentation in a single file. Literate programming tools then parse the file to produce either readable documentation or compilable source. The WEB style of literate programming was created by D.E. Knuth during the development of his TEX typsetting software.

All the original work revolves around a particular literate programming tool called WEB. Knuth says:

The philosophy behind WEB is that an experienced system programmer, who wants to provide the best possible documentation of his or her software products, needs two things simultaneously: a language like TEX for formatting, and a language like C for 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 either language separately.

The structure of a software program may be thought of as a web that is made up of many interconnected pieces. To document such a program we want to explain each individual part of the web and how it relates to its neighbours. 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 such as C or Fortran make it possible for us to specify the algorithms formally and unambigously. By combining the two, we can develop a style of programming that maximizes our ability to perceive the structure of a complex piece of software, and at the same time the documented programs can be mechanically translated into a working software system that matches the documentation.''

What follows have been written in a mixture of LATEX and \textsl{C++}. The \textsl{noweb} literate programming tool has been used to obtain a LATEX formatted version of the document as well as the C++ code which can be later compiled.


next up previous contents
Next: 1.4 How to read Up: 1. Introduction Previous: 1.2.3 D-TLBs. Distributed Memory
Francisco J. Ballesteros
1998-05-25