Generative Programming and Component Engineering

Generative Programming and Component Engineering

Peter D. Mosses

Now available: Slides

BRICS and Department of Computer Science, University of Aarhus, Denmark

pdmosses@brics.dk http://www.brics.dk/~pdm

Peter Mosses participated in the development of Denotational Semantics, in Strachey's Programming Research Group at Oxford in the early 1970's. Since moving to Aarhus in 1976, the general aim of his research in the area of semantics has been to combine solid theoretical foundations with practical applicability. He has focussed on improving the modularity of semantic descriptions, making some major advances in this direction. His most recent work provides the basis for a radically new approach to the development of semantic descriptions. He has also contributed to CoFI, the Common Framework Initiative for Algebraic Specification and Development of Software, and the design of CASL, the Common Algebraic Specification Language (http://ww.cofi.info).

Invited Talk on Modular Language Descriptions

Formal semantic descriptions of full-scale programming languages can be notoriously difficult to write, as well as to read. Writing a description of a language usually starts from scratch: reuse from previous language descriptions requires first locating a relevant one, then manually copying bits of it -- perhaps with extensive reformulation. Semantic descriptions are often intricate and intimidating documents to read, requiring a good grasp of the formalism used, as well an understanding of the interplay between the parts of the description concerned with different language constructs. Evolution of semantic descriptions, to cope with small changes or extensions to the described language, may require global reformulation.

In other words: however elegant the theoretical foundations of semantic descriptions may be, their pragmatic aspects are often reminiscent of programming large systems before modern software engineering techniques were introduced. A good dose of 'semantics engineering' is needed: analogous partly to component engineering (raising the level of modularization and analysis in semantic descriptions), partly to the use of domain-specific formalisms (elevating semantic descriptions to compact domain-specific notations that are easier to read, write and maintain).

The most extreme modularization imaginable in semantic descriptions is when each individual programming construct is described as a separate and independent component. For instance, consider a particular kind of conditional statement: its description is to be independent of whether evaluating the condition might have side-effects, throw exceptions, etc. Such modules could be made available in a repository; a description of a complete language would then merely refer to the required modules, which must not need any adaptation when combined. Reuse would be encouraged, and made explicit. The designer of a new language would be free to focus on the description of novel constructs.

Unfortunately, some well-known semantic frameworks (e.g., conventional Structural Operational Semantics and Denotational Semantics) do not allow such extreme modularization as envisaged above: the description of each language construct inherently depends on which other (kinds of) constructs are included in the language being described. Other frameworks go quite a long way towards it (e.g., Monadic Denotational Semantics, and the Montages variant of Abstract State Machines). The following two lesser-known frameworks have recently been adapted specifically to support extreme modularization:

  • Action Semantics -- a hybrid of operational and denotational semantics, developed since the end of the 80's (not to be confused with the action semantics of UML); and

  • Modular SOS (MSOS) -- a variant of Structural Operational Semantics where labels on transitions are fully exploited.

Action Semantics appears to be an appropriate basis for generation of prototype compilers, and some tool support for developing and validating semantic descriptions has been implemented. MSOS has so far been used in earnest only for defining the Action Notation used in Action Semantics, and for teaching semantics. Both frameworks are quite unbiased towards description of particular kinds of programming languages, and their support for extreme modularization should make them especially attractive for describing domain-specific languages.