Paradigms | imperative, structured, modular, data and procedure hiding, concurrent |
---|---|
Family | Wirth/Modula |
Designed by | Niklaus Wirth |
First appeared | 1978 |
Typing discipline | Static, strong, safe |
Scope | Lexical (static) |
Platform | Lilith (AMD 2901) |
OS | Cross-platform |
Filename extensions | .mod, .m2, .def, .MOD, .DEF, .mi, .md |
Website | www |
Major implementations | |
ETH compiler written by Niklaus Wirth GNU Modula-2 ADW Modula-2 | |
Dialects | |
PIM2, PIM3, PIM4, ISO | |
Influenced by | |
Modula, Mesa, Pascal, ALGOL W, Euclid | |
Influenced | |
Modula-2+, Modula-3, Oberon, Ada, Fortran 90, Lua, Seed7, Zonnon, Modula-GM |
Modula-2 is a structured, procedural programming language developed between 1977 and 1985/8 by Niklaus Wirth at ETH Zurich. It was created as the language for the operating system and application software of the Lilith personal workstation. [1] It was later used for programming outside the context of the Lilith.
Wirth viewed Modula-2 as a successor to his earlier programming languages Pascal and Modula. [2] [3] The main concepts are:
The language design was influenced by the Mesa language and the Xerox Alto, both from Xerox PARC, that Wirth saw during his 1976 sabbatical year there. [4] The computer magazine Byte devoted the August 1984 issue to the language and its surrounding environment. [5]
Wirth created the Oberon series of languages as the successor to Modula-2, while others (particularly at Digital Equipment Corporation and Acorn Computers, later Olivetti) developed Modula-2 into Modula-2+ and later Modula-3.
Modula-2 is a general purpose procedural language suitable for both systems programming and applications programming. The syntax is based on Wirth's earlier language, Pascal, with some elements and syntactic ambiguities removed. The module concept, designed to support separate compilation and data abstraction; and direct language support for multiprogramming were added.
The language allows the use of one-pass compilers. Such a compiler by Gutknecht and Wirth was about four times faster than earlier multi-pass compilers. [6]
Here is an example of the source code for the "Hello world" program:
MODULEHello;FROMSTextIOIMPORTWriteString;BEGINWriteString("Hello World!")ENDHello.
A Modula-2 module may be used to encapsulate a set of related subprograms and data structures, and restrict their visibility from other parts of the program. 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. Except for standard identifiers, no object from the outside is visible inside a module unless explicitly imported; no internal module object is visible from the outside unless explicitly exported.
Suppose module M1 exports objects a, b, c, and P by enumerating its identifiers in an explicit export list
DEFINITIONMODULEM1;EXPORTQUALIFIEDa,b,c,P;...
Then the objects a, b, c, and P from module M1 are known outside module M1 as M1.a, M1.b, M1.c, and M1.P. They are exported in a qualified manner to the outside (assuming module M1 is global). The exporting module's name, i.e. M1, is used as a qualifier followed by the object's name.
Suppose module M2 contains the following IMPORT declaration
MODULEM2;IMPORTM1;...
Then this means that the objects exported by module M1 to the outside of its enclosing program can now be used inside module M2. They are referenced in a qualified manner: M1.a, M1.b, M1.c, and M1.P. Example:
...M1.a:=0;M1.c:=M1.P(M1.a+M1.b);...
Qualified export avoids name clashes. For example, if another module M3 exports an object called P, then the two objects can be distinguished since M1.P differs from M3.P. It does not matter that both objects are called P inside their exporting modules M1 and M3.
An alternative method exists. Suppose module M4 is formulated as this:
MODULEM4;FROMM1IMPORTa,b,c,P;
This means that objects exported by module M1 to the outside can again be used inside module M4, but now by mere references to the exported identifiers in an unqualified manner as: a, b, c, and P. Example:
...a:=0;c:=P(a+b);...
This method of import is usable if there are no name clashes. It allows variables and other objects to be used outside their exporting module in the same unqualified, manner as inside the exporting module.
The export and import rules not only safeguard objects against unwanted access, but also allow a cross-reference of the definition of every identifier in a program to be created. This property helps with the maintenance of large programs containing many modules.
The language provides for single-processor concurrency (monitors, coroutines and explicit transfer of control) and for hardware access (absolute addresses, bit manipulation, and interrupts). It uses a nominal type system.
There are two major dialects of Modula-2. The first is PIM, named for the book Programming in Modula-2 by Niklaus Wirth. [4] There were three major editions of PIM: the second, third (corrected), and fourth. Each describes slight variants of the language. The second major dialect is ISO, named for the standardization effort by the International Organization for Standardization. Here are a few of the differences among them.
EXPORT
clause in definition modules.SIZE
needs to be imported from module SYSTEM
EXPORT
clause from definition modules following the observation that everything within a definition module defines the interface to that module, hence the EXPORT
clause was redundant.SIZE
is pervasive (visible in any scope without import)MOD
operator when the operands are negative.ARRAY OF CHAR
strings to be terminated by ASCII NUL, even if the string fits exactly into its array.COMPLEX
and LONGCOMPLEX
, exceptions, module termination (FINALLY
clause) and a complete standard input/output (I/O) library. There are many minor differences and clarifications. [7] There are several supersets of Modula-2 with language extensions for specific application domains:
There are several derivative languages that resemble Modula-2 very closely but are new languages in their own right. Most are different languages with different purposes and with strengths and weaknesses of their own:
Many other current programming languages have adopted features of Modula-2.
PIM [2,3,4] defines 40 reserved words:
AND ELSIF LOOP REPEAT ARRAY END MOD RETURN BEGIN EXIT MODULE SET BY EXPORT NOT THEN CASE FOR OF TO CONST FROM OR TYPE DEFINITION IF POINTER UNTIL DIV IMPLEMENTATION PROCEDURE VAR DO IMPORT QUALIFIED WHILE ELSE IN RECORD WITH
PIM [3,4] defines 29 built-in identifiers:
ABS EXCL LONGINT REAL BITSET FALSE LONGREAL SIZE BOOLEAN FLOAT MAX TRUE CAP HALT MIN TRUNC CARDINAL HIGH NIL VAL CHAR INC ODD CHR INCL ORD DEC INTEGER PROC
Modula-2 is used to program many embedded systems.
Cambridge Modula-2 by Cambridge Microprocessor Systems is based on a subset of PIM4 with language extensions for embedded development. The compiler runs on DOS and it generates code for Motorola 68000 series (M68k) based embedded microcontrollers running a MINOS operating system.
Mod51 by Mandeno Granville Electronics is based on ISO Modula-2 with language extensions for embedded development following IEC 1131, an industry standard for programmable logic controllers (PLC) closely related to Modula-2. The Mod51 compiler generates standalone code for 80C51 based microcontrollers.
Delco Electronics, then a subsidiary of GM Hughes Electronics, developed a version of Modula-2 for embedded control systems starting in 1985. Delco named it Modula-GM. It was the first high-level programming language used to replace machine code (language) for embedded systems in Delco's engine control units (ECUs). This was significant because Delco was producing over 28,000 ECUs per day in 1988 for GM. This was then the world's largest producer of ECUs. [18] The first experimental use of Modula-GM in an embedded controller was in the 1985 Antilock Braking System Controller which was based on the Motorola 68xxx microprocessor, and in 1993 Gen-4 ECU used by the Champ Car World Series Championship Auto Racing Teams (CART) and Indy Racing League (IRL) teams. [19] The first production use of Modula-GM was its use in GM trucks starting with the 1990 model year vehicle control module (VCM) used to manage GM Powertrain's Vortec engines. Modula-GM was also used on all ECUs for GM's 90° Buick V6 engine family 3800 Series II used in the 1997-2005 model year Buick Park Avenue. The Modula-GM compilers and associated software management tools were sourced by Delco from Intermetrics.
Modula-2 was selected as the basis for Delco's high level language because of its many strengths over other alternative language choices in 1986. After Delco Electronics was spun off from GM (with other component divisions) to form Delphi Automotive Systems in 1995, global sourcing required that a non-proprietary high-level software language be used. ECU embedded software now developed at Delphi is compiled with commercial compilers for the language C.
The satellites of the Russian radionavigation-satellite service framework GLONASS, similar to the United States Global Positioning System (GPS), are programmed in Modula-2. [20]
Turbo Modula-2 was a compiler and an integrated development environment for MS-DOS developed, but not published, by Borland. Jensen and Partners, which included Borland cofounder Niels Jensen, bought the unreleased codebase and turned it into TopSpeed Modula-2. It was eventually sold to Clarion, now SoftVelocity, who then offered the Modula-2 compiler as part of its Clarion product line at that time. [43]
A Zilog Z80 CP/M version of Turbo Modula-2 was briefly marketed by Echelon under license from Borland. A companion release for Hitachi HD64180 was sold by Micromint as a development tool for their SB-180 single-board computer. [44]
IBM had a Modula-2 compiler for internal use which ran on both OS/2 and AIX, and had first class support in IBM's E2 editor. [45] IBM Modula-2 was used for parts of the OS/400 Vertical Licensed Internal Code (effectively the kernel of OS/400). [46] This code was mostly replaced with C++ when OS/400 was ported to the IBM RS64 processor family, although some remains in modern releases of the operating system. [47] [48] A Motorola 68000 backend also existed, which may have been used in embedded systems products. [45]
Modula-2 is used to program some operating systems (OSs). The Modula-2 module structure and support are used directly in two related OSs.
The OS named Medos-2 , for the Lilith workstation, was developed at ETH Zurich, by Svend Erik Knudsen with advice from Wirth. It is a single user, object-oriented operating system built from Modula-2 modules. [49] [50] [51]
The OS named Excelsior , for the Kronos workstation, was developed by the Academy of Sciences of the Soviet Union, Siberian branch, Novosibirsk Computing Center, Modular Asynchronous Developable Systems (MARS) project, Kronos Research Group (KRG). It is a single user system based on Modula-2 modules. [52]
The Modula programming language is a descendant of the Pascal language. It was developed in Switzerland, at ETH Zurich, in the mid-1970s by Niklaus Wirth, the same person who designed Pascal. The main innovation of Modula over Pascal is a module system, used for grouping sets of related declarations into program units; hence the name Modula. The language is defined in a report by Wirth called Modula. A language for modular multiprogramming published 1976.
Niklaus Emil Wirth was a Swiss computer scientist. He designed several programming languages, including Pascal, and pioneered several classic topics in software engineering. In 1984, he won the Turing Award, generally recognized as the highest distinction in computer science, "for developing a sequence of innovative computer languages".
Oberon is a general-purpose programming language first published in 1987 by Niklaus Wirth and the latest member of the Wirthian family of ALGOL-like languages. Oberon was the result of a concentrated effort to increase the power of Modula-2, the direct successor of Pascal, and simultaneously to reduce its complexity. Its principal new feature is the concept of type extension of record types. It permits constructing new data types on the basis of existing ones and to relate them, deviating from the dogma of strictly static typing of data. Type extension is Wirth's way of inheritance reflecting the viewpoint of the parent site. Oberon was developed as part of the implementation of an operating system, also named Oberon at ETH Zurich in Switzerland. The name was inspired both by the Voyager space probe's pictures of the moon of the planet Uranus, named Oberon, and because Oberon is famous as the king of the elfs.
Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal.
An object-oriented operating system is an operating system that is designed, structured, and operated using object-oriented programming principles.
Modula-3 is a programming language conceived as a successor to an upgraded version of Modula-2 known as Modula-2+. While it has been influential in research circles it has not been adopted widely in industry. It was designed by Luca Cardelli, James Donahue, Lucille Glassman, Mick Jordan, Bill Kalsow and Greg Nelson at the Digital Equipment Corporation (DEC) Systems Research Center (SRC) and the Olivetti Research Center (ORC) in the late 1980s.
The Oberon System is a modular, single-user, single-process, multitasking operating system written in the programming language Oberon. It was originally developed in the late 1980s at ETH Zurich. The Oberon System has an unconventional visual text user interface (TUI) instead of a conventional command-line interface (CLI) or graphical user interface (GUI). This TUI was very innovative in its time and influenced the design of the Acme text editor for the Plan 9 from Bell Labs operating system.
Component Pascal is a programming language in the tradition of Niklaus Wirth's Pascal, Modula-2, Oberon and Oberon-2. It bears the name of the language Pascal and preserves its heritage, but is incompatible with Pascal. Instead, it is a minor variant and refinement of Oberon-2 with a more expressive type system and built-in string support. Component Pascal was originally named Oberon/L, and was designed and supported by a small ETH Zürich spin-off company named Oberon microsystems. They developed an integrated development environment (IDE) named BlackBox Component Builder. Since 2014, development and support has been taken over by a small group of volunteers. The first version of the IDE was released in 1994, as Oberon/F. At the time, it presented a novel approach to graphical user interface (GUI) construction based on editable forms, where fields and command buttons are linked to exported variables and executable procedures. This approach bears some similarity to the code-behind way used in Microsoft's .NET 3.0 to access code in Extensible Application Markup Language (XAML), which was released in 2008.
The DISER Lilith is a custom built workstation computer based on the Advanced Micro Devices (AMD) 2901 bit slicing processor, created by a group led by Niklaus Wirth at ETH Zurich. The project began in 1977, and by 1984 several hundred workstations were in use. It has a high resolution full page portrait oriented cathode ray tube display, a mouse, a laser printer interface, and a computer networking interface. Its software is written fully in Modula-2 and includes a relational database program named Lidas.
Oberon-2 is an extension of the original Oberon programming language that adds limited reflective programming (reflection) and object-oriented programming facilities, open arrays as pointer base types, read-only field export, and reintroduces the FOR
loop from Modula-2.
Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.
Kronos is a series of 32-bit processor equipped printed circuit board systems, and the workstations based thereon, of a proprietary hardware architecture developed in the mid-1980s in Akademgorodok, a research city in Siberia, by the Academy of Sciences of the Soviet Union, Siberian branch, Novosibirsk Computing Center, Modular Asynchronous Developable Systems (MARS) project, Kronos Research Group (KRG).
A2 is a modular, object-oriented operating system with unconventional features including automatic garbage-collected memory management, and a zooming user interface. It was developed originally at ETH Zurich in 2002. It is free and open-source software under a BSD-like license.
Algorithms + Data Structures = Programs is a 1976 book written by Niklaus Wirth covering some of the fundamental topics of system engineering, computer programming, particularly that algorithms and data structures are inherently related. For example, if one has a sorted list one will use a search algorithm optimal for sorted lists.
BlackBox Component Builder is an integrated development environment (IDE) optimized for component-based software development developed by a small spin-off company, Oberon microsystems AG, of ETH Zurich in Switzerland. The IDE consists of development tools, a library of reusable components, a framework that simplifies developing robust custom components and applications, and a run-time environment for components.
Active Oberon is a general purpose programming language developed during 1996-1998 by the group around Niklaus Wirth and Jürg Gutknecht at the Swiss Federal Institute of Technology in Zürich. It is an extension of the programming language Oberon. The extensions aim at implementing active objects as expressions for parallelism. Compared to its predecessors, Oberon and Oberon-2, Active Oberon adds objects, system-guarded assertions, preemptive priority scheduling and a changed syntax for methods. Objects may be active, which means that they may be threads or processes. As it is tradition in the Oberon world, the Active Oberon language compiler is implemented in Active Oberon. The operating system named Active Object System (AOS) in 2002, then due to trademark issues, renamed Bluebottle in 2005, and then renamed A2 in 2008, especially the kernel, synchronizes and coordinates different active objects.
The Ceres Workstation was a workstation computer built by Niklaus Wirth's group at ETH Zurich in 1987. The central processing unit (CPU) is a National Semiconductor NS32000, and the operating system, named Oberon System is written fully in the object-oriented programming language Oberon. It is an early example of an operating system using basic object-oriented principles and garbage collection on the system level and a document centered approach for the user interface (UI), as envisaged later with OpenDoc. Ceres was a follow-up project to the Lilith workstation, based on AMD bit slicing technology and the programming language Modula-2.
Jürg Gutknecht is a Swiss computer scientist. He developed, with Niklaus Wirth, the programming language Oberon and the corresponding operating system Oberon.
Zonnon is a general purpose programming language in the line or family of the preceding languages Pascal, Modula, and Oberon. Jürg Gutknecht is the author.
Hanspeter Mössenböck is an Austrian computer scientist. He is professor of practical computer science and systems software at the Johannes Kepler University Linz and leads the institute of systems software.
Photo of the floppy disk