Modula-2
Modula-2 is a computer programming language invented by Niklaus Wirth at ETH around 1978, as a successor to Modula, another language by him that was never implemented. The Modula-2 language is loosely based upon the Mesa programming language, from Xerox, that Wirth saw during his 1976 sabbatical year at Xerox PARC.
Description
Modula-2 is a general purpose procedural language, sufficiently flexible to do systems work, but with much broader application. In particular, it was designed to support separate compilation and data abstraction in a straightforward way. Much of the syntax is based on Wirth's earlier and better-known language, Pascal. Modula-2 was designed to be broadly similar to Pascal, with some elements removed and the important addition of the module concept, and direct language support for multiprogramming.
The Modula-2 module may be used to encapsulate a set of related subprograms and data structures, and restrict their visibility from other portions of the program. The module design implemented the data abstraction feature of Modula-2 in a very clean way. Modula-2 programs are composed of modules, each of which is made up of two parts: a definition module, the interface portion, which contains only those parts of the subsystem that are exported (visible to other modules), and an implementation module, which contains the working code that is internal to the module.
The language has strict scope control. Thus, supposing ModuleA exports identifiers A, B and C, and suppose ModuleB contains the declaration
IMPORT ModuleA;
Then this means that references to the exported identifiers must still be explicitly qualified by the exporting module name, thus: "ModuleA.A", "ModuleA.B", "ModuleA.C". The only way to avoid this qualification is to individually import the identifiers as follows:
FROM ModuleA IMPORT A, B, C;
This may seem unnecessarily restrictive and verbose. But in fact it has the pleasant side-effect of providing automatic cross-referencing of the definition of every identifier in a program: if the identifier is qualified by a module name, then the definition comes from that module. Otherwise if it occurs unqualified, simply search backwards, and you will either encounter a declaration of that identifier, or its occurrence in an IMPORT statement which names the module it comes from. This property becomes very useful when trying to understand large programs containing many modules.
The language provides for (limited) single-processor concurrency (monitors, coroutines and explicit transfer of control) and for hardware access (absolute addresses, bit manipulation, and interrupts). It uses name equivalence.
Related languages
Although Modula-2 is by far the best-known and most widely used variant, there are several languages which are related in one way or another: the original, and quite different, Modula (intended for systems implementation), Modula-2+, Modula-2*, Modula-3 (by DEC and Olivetti; adding garbage collection), Oberon (another, later, Wirth design), Oberon-2, and a number of others. These should not be regarded as "better versions" or "replacements" for Modula-2; most are different languages with different purposes, and with strengths and weaknesses of their own.
Along with C and Ada, Modula-2 is often regarded as one of the three most significant "modern" programming languages (ie, of the structured programming era). Of the three, Modula-2 is the smallest, easiest to read, easiest to learn, and cleanest designed, both syntactically and conceptually. Modula-2 was developed as the system language for the Lilith workstation, and formed the basis of the Oberon project at ETHZ. Most current programming languages have adopted many of the features of Modula-2.
Compilers
- TopSpeed (aka Clarion, aka JPI, aka Jensen and Partners) had several good 16-bit Modula-2 compilers, with nice productive IDE's. However to my knowledge they are not available anymore. For a while they came with the Clarion product though. This was the "Turbo Pascal" of Modula-2. Slightly non standard, but very popular both in business and education, an excellent toolchain.
- Canterbury Modula-2 generates Java source code
- GNU Modula2 compiler (still under development)
- Logitech had a series of Modula-2 compilers.
- The Karlsruhe Modula-2 Compiler MOCKA
- Stony Brook Modula-2
- The Ulm Modula-2 System
- Excelsior Modula-2 (xds)
External links
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.