home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / new / dev / obero / oberon-a / texts / modulatooberon.text < prev    next >
Text File  |  1993-08-23  |  30KB  |  594 lines

  1. From Modula to Oberon
  2.  
  3. N. Wirth
  4.  
  5. Abstract
  6.  
  7. The programming language Oberon is the result of a concentrated effort to
  8. increase the power of Modula-2 and simultaneously to reduce its complexity.
  9. Several features were eliminated, and a few were added in order to increase
  10. the expressive power and flexibility of the language. This paper describes
  11. and motivates the changes. The language is defined in a concise report.
  12.  
  13. Introduction
  14.  
  15. The programming language Oberon evolved from a project whose goal was the
  16. design of a modern, flexible, and efficient operating system for a
  17. single-user workstation. A principal guideline was to concentrate on
  18. properties that are genuinely essential and - as a consequence - to omit
  19. ephemeral issues. It is the best way to keep a system in hand, to make it
  20. understandable, explicable, reliable, and efficiently implementable.
  21.  
  22. Initially, it was planned to express the system in Modula-2 [1]
  23. (subsequently called Modula), as that language supports the notion of
  24. modular design quite effectively, and because an operating system has to be
  25. designed in terms of separately compilable parts with conscientiously
  26. chosen interfaces. In fact, an operating system should be no more than a
  27. set of basic modules, and the design of an application must be considered
  28. as a goal-oriented extension of that basic set: Programming is always
  29. extending a given system.
  30.  
  31. Whereas modern languages, such as Modula, support the notion of
  32. extensibility in the procedural realm, the notion is less well established
  33. in the domain of data types. In particular, Modula does not allow the
  34. definition of new data types as extensions of other, programmer-defined
  35. types in an adequate manner. An additional feature was called for, thereby
  36. giving rise to an extension of Modula.
  37.  
  38. The concept of the planned operating system also called for a highly
  39. dynamic, centralized storage management relying on the technique of garbage
  40. collection. Although Modula does not prevent the incorporation of a garbage
  41. collector in principle, its variant record feature constitutes a genuine
  42. obstacle. As the new facility for extending types would make the variant
  43. record feature superfluous, the removal of this stumbling block was a
  44. logical decision. This step, however, gave rise to a restriction (subset)
  45. of Modula.
  46.  
  47. It soon became clear that the rule to concentrate on the essential and to
  48. eliminate the inessential should not only be applied to the design of the
  49. new system, but equally stringently to the language in which the system is
  50. formulated. The application of the principle thus led from Modula to a new
  51. language. However, the adjective "new" has to be understood in proper
  52. context: Oberon evolved from Modula by very few additions and several
  53. subtractions. In relying on evolution rather than revolution we remain in
  54. the tradition of a long development that led from Algol to Pascal, then to
  55. Modula-2, and eventually to Oberon. The common traits of these languages
  56. are their procedural rather than functional model and the strict typing of
  57. data. Even more fundamental, perhaps, is the idea of abstraction: the
  58. language must be defined in terms of mathematical, abstract concepts
  59. without reference to any computing mechanism. Only if a language satisfies
  60. this criterion, can it be called "higher-level". No syntactic coating
  61. whatsoever can earn a language this attribute alone.
  62.  
  63. The definition of a language must be coherent and concise. This can only be
  64. achieved by a careful choice of the underlying abstractions and an
  65. appropriate structure combining them. The language manual must be
  66. reasonably short, avoiding the explanation of individual cases derivable
  67. from the general rules. The power of a formalism must not be measured by
  68. the length of its description. To the contrary, an overly lengthy
  69. definition is a sure symptom of inadequacy. In this respect, not complexity
  70. but simplicity must be the goal.
  71.  
  72. In spite of its brevity, a description must be complete. Completeness is to
  73. be achieved within the framework of the chosen abstractions. Limitations
  74. imposed by particular implementations do not belong to a language
  75. definition proper. Examples of such restrictions are the maximum values of
  76. numbers, rounding and truncation errors in arithmetic, and actions taken
  77. when a program violates the stated rules. It should not be necessary to
  78. supplement a language definition with a voluminous standards document to
  79. cover "unforeseen" cases.
  80.  
  81. But neither should a programming language be a mathematical theory only. It
  82. must be a practical tool. This imposes certain limits on the terseness of
  83. the formalism. Several features of Oberon are superfluous from a purely
  84. theoretical point of view. They are nevertheless retained for practical
  85. reasons, either for programmers' convenience or to allow for efficient code
  86. generation without the necessity of complex, "optimizing" pattern matching
  87. algorithms in compilers. Examples of such features are the presence of
  88. several forms of repetitive statements, and of standard procedures such as
  89. INC, DEC, and ODD. They complicate neither the language conceptually nor
  90. the compiler to any significant degree.
  91.  
  92. These underlying premises must be kept in mind when comparing Oberon with
  93. other languages. Neither the language nor its defining document reach the
  94. ideal; but Oberon approximates these goals much better than its
  95. predecessors.
  96.  
  97. A compiler for Oberon has been implemented for the NS32000 processor family
  98. and is embedded in the Oberon operating environment [8]. The compiler
  99. requires less than 50 KByte of memory, consists of 6 modules with a total
  100. of about 4000 lines of source code, and compiles itself in about 15 seconds
  101. on a workstation with a 25MHz NS32532 processor.
  102.  
  103. After extensive experience in programming with Oberon, a revision was
  104. defined and implemented. The differences between the two versions are
  105. summarised towards the end of the paper. Subsequently, we present a brief
  106. introduction to (revised) Oberon assuming familiarity with Modula (or
  107. Pascal), concentrating on the added features and listing the eliminated
  108. ones. In order to be able to start with a clean slate, the latter are taken
  109. first.
  110.  
  111. Features omitted from Modula
  112.  
  113. Data types
  114.  
  115. Variant records are eliminated, because they constitute a genuine
  116. difficulty for the implementation of a reliable storage management system
  117. based on automatic garbage collection. The functionality of variant records
  118. is preserved by the introduction of extensible data types.
  119.  
  120. Opaque types cater for the concept of abstract data type and information
  121. hiding. They are eliminated as such, because again the concept is covered
  122. by the new facility of extended record types.
  123.  
  124. Enumeration types appear to be a simple enough feature to be
  125. uncontroversial. However, they defy extensibility over module boundaries.
  126. Either a facility to extend given enumeration types has to be introduced,
  127. or they have to be dropped. A reason in favour of the latter, radical
  128. solution was the observation that in a growing number of programs the
  129. indiscriminate use of enumerations (and subranges) had led to a type
  130. explosion that contributed not to program clarity but rather to verbosity.
  131. In connection with import and export, enumerations give rise to the
  132. exceptional rule that the import of a type identifier also causes the
  133. (automatic) import of all associated constant identifiers. This exceptional
  134. rule defies conceptual simplicity and causes unpleasant problems for the
  135. implementor.
  136.  
  137. Subrange types were introduced in Pascal (and adopted in Modula) for two
  138. reasons: (1) to indicate that a variable accepts a limited range of values
  139. of the base type and to allow a compiler to generate appropriate guards for
  140. assignments, and (2) to allow a compiler to allocate the minimal storage
  141. space needed to store values of the indicated subrange. This appeared
  142. desirable in connection with packed records. Very few implementations have
  143. taken advantage of this space saving facility, because the additional
  144. compiler complexity is very considerable. Reason 1 alone, however, did not
  145. appear to provide sufficient justification to retain the subrange facility
  146. in Oberon.
  147.  
  148. With the absence of enumeration and subrange types, th