UH2@PSUVM.BITNET (Lee Sailer) (04/10/88)
Can someone supply the *exact* citation to Knuth's essay on LITERATE PROGRAMMING? Basically, his idea is that comments should explain the code as well as if they were explanations in a text book, or if you were walking another programmer thru the code so that he could take over the development or maintenance. The WEB system supports this in the extreme. In WEB, as I understand it, the programmer writes prose that describes the code to another human. When run thru one filter, this WEB file becomes a chapter in a book about that piece of code, all nicely formatted with the language keywords in bold, etc. When run thru a different filter, the WEB gets reformatted into compilable code. Notice one advantage of this---the *detailed* doumentation and specification document and the compiled source code are one and the same. When a bug is fixed in the code, the docs change simultaneously. THE BOTTOM LINE It is claimed, and supported by a few *small* empirical studies, that this approach leads to better code faster. Sort of one-man egoless programming. I've seen it work. lee
fad@think.COM (franklin a davis) (04/11/88)
In article <38798UH2@PSUVM> UH2@PSUVM.BITNET (Lee Sailer) writes: >Can someone supply the *exact* citation to Knuth's essay on LITERATE >PROGRAMMING? > Donald E. knuth, "Literate Programming," Dept. of Computer Science, Stanford University (September 1983). I wrote a short paper on this while at the Wang Institute, and looked into the system a bit. I found Knuth's idea very inspiring -- he breaks a system into big chunks, and describes each in prose, with pseudocode. The pseudocode contains lines that are like macros -- each is further detailed in a following section. By the time you're done reading, each piece of the program has been described and coded. You can then run the Web processor to produce either TeX source for a well-formatted text description of the program, or Pascal source. (There now exists CWeb, which produces troff and C source.) The central idea is that when the program is modified, both the documentation and the code are at the same place in the same source file, so both will be updated in synch. Producing the new printed or executable results is then trivial. A big assumption of Web's approach is that people know how to design a program using step-wise refinement. As I wrote last year, "The remarkable thing about his [Knuth's] example is the great ease the reader finds in following his elegant approach to creating this program. Each piece is presented in the context in which it is relevant, and not before the other pieces that are necessary background are presented. Knuth's ability to break the problem down into pieces is dazzling. However, despite its clarity, the process left me feeling that I would have a hard time producing such elegant results, even if I had mastered Web." We can't all be Donald Knuths... I think Web would have a longer learning curve than most languages, and so is likely to be used by a small set of programmer. Knuth seems to support this, concluding, "...Web seems to be specifically for the peculiar breed of people who are called computer scientists." As a software engineer, I personally interpret the distinction in this case to partly be a matter of time. Scientists may have time to tinker and groom an idea or example, but engineers generally have pressing external deadlines. (I'll probably get roasted for that last statement...) I'll end with another wonderful quote from Knuth's introduction: "During the 1970s I was coerced like everybody else into adopting the ideas of structured programming, because I couldn't bear to be found guilty of writing 'unstructured' programs. Now I have a chance to get even. By coining the phrase 'literate programming,' I am imposing a moral commitment on everyone who hears the term; surely nobody wants to admit writing an 'illiterate' program." --Franklin Davis franklin a davis Thinking Machines Corp. Cambridge, MA 02142 617-876-1111 <fad@think.com> {ihnp4, harvard, seismo}!think!fad "Roll away...the dew!"
daveb@geac.UUCP (David Collier-Brown) (04/12/88)
In article <19359@think.UUCP> fad@balder.think.com.UUCP (franklin a davis) writes: > "The remarkable thing about his [Knuth's] example is the great ease > the reader finds in following his elegant approach to creating this > program. Each piece is presented in the context in which it is > relevant, and not before the other pieces that are necessary > background are presented. Knuth's ability to break the problem down > into pieces is dazzling. However, despite its clarity, the process > left me feeling that I would have a hard time producing such elegant > results, even if I had mastered Web." Well, it is hard, but one of the best techniques for writing WEB (or anything else with a specific structure) is to use an outline processor. I re-wrote some C code in tWEB by roughing up some pseudo-code for it, shuffling the lines around in a so-called idea processor to get a nice organization, and then sending the file back to the machine with weave and tangle on it to finish. The result looks rather like it was designed in WEB, and I can assure you it **wasn't**. --dave (you can make a leather purse out of a sow's ear) c-b -- David Collier-Brown. {mnetor yunexus utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.