Analysis of Literate Programs from the Viewpoint of Reuse

Analysis of Literate Programs from the Viewpoint of Reuse

Software—Concepts and Tools (1996) 18: 35–46 Software—Concepts and Tools © Springer-Verlag 1997 Analysis of Literate Programs from the Viewpoint of Reuse Bart Childs Department of Computer Science, Texas A&M University, USA e-mail: [email protected] Johannes Sametinger CD Laboratory of Software Engineering, University of Linz, A-4040 Linz, Austria e-mail: [email protected] Abstract. Donald Knuth created the WEB system for Knuth’s style of literate programming as prototypical. literate programming when he wrote the second version of It was used in writing the second version of the TEX T X, a book-quality formatting system. Levy later created E typesetting system [11, 12] and its related components. CWEB, which is based on Knuth’s WEB using the C programming language and supporting development using This WEB system, as he used it, leads to the C and C++ programming languages. Krommes’ FWEB is based on CWEB and supports several programming • top-down and bottom-up programming through a languages. We analyze some parts of these systems from the structured pseudocode, viewpoint of reuse. • programming in sections, generally a screen or We make reuse comparisons of four elements of the TEX less of integrated documentation and code (where system: TEX, METAFONT, DVItype and METAPOST. We also compare the primary filters (tangle and weave) of section in this use is similar to a paragraph in CWEB and FWEB. We analyze the code and integral prose), documentation, considering similarities of chapters, lines • typeset documentation (after all, it was for and in and words. TEX), With this study we demonstrate that both code and • pretty-printed code where the keywords are in documentation can and should be reused systematically and that there is a need for methods and tools for doing so. bold, user-supplied names in italics, etc., and Literate programming and software reuse are by no means in • extensive reading aids which are automatically contradiction. However, current literate programming generated, including table of contents and index. systems do not explicitly support software reuse, even though reuse was common in their development. The value of each of these items depends on the pro- grammer, as always. For example, the index mentioned in the last item can be supplemented by Keywords: software reuse, literate programming, TEX, user-supplied entries in addition to those automatically WEB, case study generated (which are similar to compiler cross reference lists). If the author does not furnish these, the modifier literate cannot be justified, in our 1. Introduction opinion. For example, in TEX [12] Knuth entered nearly a thousand extra index entries, of which more The literate programmer should keep in mind that the than 600 were unique. human reader is as important as the machine reader. Pappas stated that a literate programming approach Human readers are necessary for maintenance provides benefits in writing reusable code [23]. He activities, an area of prime importance in the study of emphasized that reusable software requires “more software engineering. We agree with Knuth’s claim than just following coding guidelines”. Further, “if a that literate programming is a process which should software component gives a programmer the lead to more carefully constructed programs with impression that it will take almost as much time to better, relevant ‘systems’ documentation [16]. We take 36 Childs, Sametinger: Analysis of Literate Programs from the Viewpoint of Reuse understand ... as it will to write ... (it) will not be “systems documentation” would be a significant reused!” We feel that the quality, locality and factor. integration of documentation that is provided by Knuth surveyed a number of users and concluded Knuth’s style of literate programming could have a that Pascal was the best language choice because it dramatic effect on reuse. seemed to be everybody’s second best language and We have chosen Knuth’s sources for his TEX most versions of Pascal had the facilities to be a system and descendent literate programming systems reasonable host for writing a ‘systems program’. (C as examples because: was not commonly available at that time, 1980.) Knuth honored many of the ‘standard’ aspects of • they are in the public domain, Pascal, used some common extensions that were of • they are commonly available, great benefit, and extended Pascal with some WEB • they are well documented, features. There have been a number of posts to news • they are consistent and complete, groups of like “literate programming is brain dead • they are written in Knuth’s WEB (and descendent because I don’t like programming in a monolith”. It is systems) for literate programming, obvious that the only reason Knuth’s WEB did not use • they are of reasonable size for our planned investi- include files is that it was not common in Pascal(s) in gation, i.e., big enough for serious investigation 1980! Features of the WEB system that enhanced and small enough to complete the investigation portability included macros, facilities for converting within a reasonable amount of time, and long, readable variable names to arbitrary compiler • Knuth is an experienced, careful, accurate and limitations, and many others. meticulous literate programmer. Knuth’s design decisions were based on making the TEX system portable to a wide variety of systems. In Chapter 2 we discuss some of Knuth’s design He accomodated a number of characteristics that may decisions in order to clarify some frequent misunder- seem perverse today. For example, he programmed standings. Chapter 3 contains information about soft- using long variable names that were generally words ware reuse and why we believe that reuse in literate from the dictionary connected by underscores. programming is important. In Chapter 4 we present Because of the existence of Pascal compilers with an overview of the systems we considered for arbitrary requirements, the filter that extracts code investigation. In Chapter 5 we explain how the results (tangle) produced code that was all uppercase, no were obtained and then we present the results in underscores, at most eight characters long, and unique Chapter 6. Discussions and interpretations follow in in the first seven. Chapter 7. Finally, a short summary appears in Knuth makes a token payment to the first person to Chapter 8. find an error. Updates to the TEX systems are issued periodically. The errors that have been found and corrected are widely distributed and its evolution has 2. A View of some of Knuth’s Design been well documented also [15]. We will not address Decisions these errors, but that could be a fertile area of study. (Incidentally, Knuth has doubled the ‘token payment’ We wish to enable understanding of some of Knuth’s with successive revisions of TEX and now maintains decisions because the results of them have often been it at a rather significant level.) misunderstood and misused in what we view as unjust criticism. Knuth released the first version of TEX in 1978. It 3. Software Reuse was written in the SAIL language and was generally available only on DEC 10’s and 20’s. An enthuastic Software reuse is the process of creating software following developed in the academic and research lab systems from existing software rather than building communities with such machines (and a few ports them from scratch. Reusable software has many were made to other systems.) A number of limitations benefits, including the following most common ones in the original TEX system and the fact that DEC [5, 19, 22]: halted manufacture of the 36-bit systems led to the decision to rewrite and extend TEX. Knuth included • reduction of development time and redundant portability as a prime concern and believed that work Childs, Sametinger: Analysis of Literate Programs from the Viewpoint of Reuse 37 • ease of documentation, maintenance, and modifi- We studied the following versions of the codes: cation TEX 3.141, METAFONT 2.71, METAPOST 0.63, • improvement of software performance and DVItype 3.4, CWEB 2.99++, and FWEB 1.30a. software quality 4.1 The TEX System • encouragement of expertise sharing and inter- We studied four WEBs from the TEX system: TEX, a communication among designers book-quality formatting system [11, 12]; META- • smaller programming teams for the construction of FONT, a system that enables a programmer/artist to more complex software systems create a family of fonts for TEX [13, 14]; DVItype, a In the context of literate programming we are prototypical reader of dvi files that are the output of interested in technical aspects rather than in TEX [10]; and METAPOST, a close relative of managemental, cultural, organizational, economical or METAFONT that enables the creation of high-quality legal issues, which, without any doubt, have a big graphics as encapsulated PostScript files [7, 8]. An influence on successful reuse of software. Technical outstanding feature of the TEX system is the complete aspects of software reuse have many facets, too, e.g., and careful documentation that it includes. Several of ad-hoc reuse vs institutionalized reuse, black box reuse the WEBs were written by Knuth himself and some vs white box reuse, code reuse vs design reuse, and others were obviously carefully reviewed by him. code scavenging vs as-is reuse. Since McIlroy’s vision of standard catalogs in 1969, the term software 4.1.1 TEX. The TEX processor converts a plain component has played a major role in the context of text file containing document markup into a device- software reuse. Many definitions and taxonomies of independent graphics metafile. It inputs a number of software components exist, e.g., in [4, 27]. other files in this process to get font charcteristics, We believe that the idea of literate programming is document styles, etc.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us