Last updated
Paradigm imperative, structured, modular, data and procedure hiding, concurrent
Designed by Niklaus Wirth
First appeared1978
Typing discipline strong, static
OS Cross-platform
Filename extensions .mod, .m2, .def, .MOD, .DEF, .mi, .md
Major implementations
ETH compiler written by Niklaus Wirth
GNU Modula-2
ADW Modula-2
Influenced by
Modula, Mesa, Pascal, Algol-W, Euclid
Modula-3, Oberon, Ada, Fortran 90, Lua, Seed7, Zonnon, Modula-GM

Modula-2 is a structured, procedural programming language developed between 1977 and 1985 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 principal concepts are:

  1. The module as a compilation unit for separate compilation
  2. The coroutine as the basic building block for concurrent processes
  3. Types and procedures that allow access to machine-specific data.

The language design was influenced by the Mesa language and the Xerox Alto, both from Xerox, that Wirth saw during his 1976 sabbatical year at Xerox PARC. [4] The computer magazine BYTE devoted the August 1984 issue to the language and its surrounding environment. [5]

Modula-2 was followed by Modula-3 and later the Oberon series of languages.


Modula-2 is a general purpose procedural language, sufficiently flexible to do systems programming, 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 and syntactic ambiguities removed and the important addition of the module concept, and direct language support for multiprogramming.

The language allows compilation in a single pass, and in a compiler of 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.

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. In particular the scope of a module can be considered as an impenetrable wall: Except for standard identifiers no object from the outer world 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


Then the objects a, b,c, and P from module M1 become now known outside module M1 as M1.a, M1.b, M1.c, and M1.P. They are exported in a qualified manner to the universe (assumed 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


Then this means that the objects exported by module M1 to the universe of its enclosing program can now be used inside module M2. They are referenced in a qualified manner like this: M1.a, M1.b, M1.c, and M1.P. Example:


Qualified export avoids name clashes: For instance, if another module M3 would also export an object called P, then we can still distinguish the two objects, since M1.P differs from M3.P. Thanks to the qualified export it does not matter that both objects are called P inside their exporting modules M1 and M3.

There is an alternative technique available, which is in wide use by Modula-2 programmers. Suppose module M4 is formulated as this


Then this means that objects exported by module M1 to the universe can again be used inside module M4, but now by mere references to the exported identifiers in an "unqualified" manner like this: a, b, c, and P. Example:


This technique of unqualifying import allows use of variables and other objects outside their exporting module in exactly the same simple, i.e. unqualified, manner as inside the exporting module. The walls surrounding all modules have now become irrelevant for all those objects for which this has been explicitly allowed. Of course unqualifying import is only usable if there are no name clashes.

These export and import rules may seem unnecessarily restrictive and verbose. But they do not only safeguard objects against unwanted access, but also have 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 a nominal type system.


There are two major dialects of Modula-2. The first is PIM, named after the book "Programming in Modula-2" by Niklaus Wirth. There were three major editions of PIM, the second, third (corrected) and fourth editions, each describing slight variants of the language. The second major dialect is ISO, from the standardization effort by the International Organization for Standardization. Here are a few of the differences amongst them.


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.

Language elements

Reserved words

PIM [2,3,4] defines the following 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 

Built-in identifiers

PIM [3,4] defines the following 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 

Use in embedded systems

Cambridge Modula-2

Cambridge Modula-2 by Cambridge Microprocessor Systems is based on a subset of PIM4 with language extensions for embedded development. The compiler runs on MS-DOS and it generates code for M68k-based embedded microcontrollers running the MINOS operating system.


Mod51 by Mandeno Granville Electronics is based on ISO Modula-2 with language extensions for embedded development following IEC1131, 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 language used to replace machine language code 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. [19] 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 CART (Championship Auto Racing Teams) and IRL (Indy Racing League) teams. [20] The first production use of Modula-GM was its use in GM trucks starting with the 1990 model year VCM (Vehicle Control Module) used to manage GM Powertrain's Vortec engines. Modula-GM was also used on all ECUs for GM's 90° Buick V6 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 in 1997, global sourcing required that a non-proprietary high-level software language be used. ECU embedded software now developed at Delphi is compiled with commercial C compilers.

Russian GPS satellites

According to the Modula-2 article in the Russian Wikipedia, all satellites of the Russian GPS framework GLONASS are programmed in Modula-2.[ citation needed ]


Turbo Modula-2

Turbo Modula-2 was both a compiler and an Integrated Development Environment for the Modula-2 programming language running on MS-DOS, developed by Borland, but never released by them. Instead, a group including Borland cofounder Niels Jensen, acting as Jensen and Partners, bought the unreleased codebase and redeveloped and released it as TopSpeed Modula-2. TopSpeed was eventually sold to Clarion, now owned by SoftVelocity, which still offers the Modula-2 compiler as part of its Clarion product line.

A Z80 CP/M version of Turbo Modula-2 was briefly marketed by Echelon, Inc. under license from Borland. A companion release for Hitachi HD64180 was marketed by Micromint, Inc. as a development tool for their SB-180 single-board computer.


Related Research Articles

ANSI C, ISO C and Standard C are successive standards for the C programming language published by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO). Historically, the names referred specifically to the original and best-supported version of the standard. Software developers writing in C are encouraged to conform to the standards, as doing so helps portability between compilers.

Mesa is a programming language developed in the late 1970s at the Xerox Palo Alto Research Center in Palo Alto, California, United States. The language name was a pun based upon the programming language catchphrases of the time, because Mesa is a "high level" programming language.

The Modula programming language is a descendant of the Pascal programming language. It was developed in Switzerland in the 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 Wirth Swiss computer scientist

Niklaus Emil Wirth is a Swiss computer scientist. He has 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 (programming language) programming language

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 the construction of new data types on the basis of existing ones and to relate them, deviating from the dogma of strictly static data typing. Type extension is Wirth's way of inheritance reflecting the viewpoint of the parent site. Oberon was developed as part of the implementation of the Oberon operating system at ETH Zurich in Switzerland. The name is from the moon of Uranus, Oberon.

Pascal (programming language) Programming language

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 in honour of the French mathematician, philosopher and physicist Blaise Pascal.

C++ General-purpose programming language

C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.

Modula-3 programming language

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.

Oberon (operating system) operating system

The Oberon System is a modular, single-user, single-process, multitasking operating system written in the programming language of the same name. It was originally developed in the late 1980s at ETH Zürich. The Oberon System has an unconventional visual text user interface instead of a conventional CLI or 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 Pascal programming language and it preserves its heritage, but it is not compatible 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 designed and supported by a small ETH Zürich spin-off company called Oberon microsystems under the name Oberon/L. They developed an IDE called BlackBox Component Builder. Since 2014 development and support has been taken over by a small group of volunteers. At the time the first version of the IDE was released 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 XAML, which was released in 2008.

Oberon-2 programming language

Oberon-2 is an extension of the original Oberon programming language that adds limited reflection and object-oriented programming facilities, open arrays as pointer base types, read-only field export and reintroduces the FOR loop from Modula-2.

In computer science, type safety is the extent to which a programming language discourages or prevents type errors. A type error is erroneous or undesirable program behaviour caused by a discrepancy between differing data types for the program's constants, variables, and methods (functions), e.g., treating an integer (int) as a floating-point number (float). Type safety is sometimes alternatively considered to be a property of a computer program rather than the language in which that program is written; that is, some languages have type-safe facilities that can be circumvented by programmers who adopt practices that exhibit poor type safety. The formal type-theoretic definition of type safety is considerably stronger than what is understood by most programmers.

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.

FAAC or Freeware Advanced Audio Coder is a software project which includes the AAC encoder FAAC and decoder FAAD2. It supports MPEG-2 AAC as well as MPEG-4 AAC. It supports several MPEG-4 Audio object types, file formats, multichannel and gapless encoding/decoding and MP4 metadata tags. The encoder and decoder is compatible with standard-compliant audio applications using one or more of these object types and facilities. It also supports Digital Radio Mondiale.

Programming languages are used for controlling the behavior of a machine. Like natural languages, programming languages conform to rules for syntax and semantics.


OpenLisp is a programming language in the Lisp family developed by Christian Jullien from Eligis. It conforms to the international standard for ISLISP published jointly by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), ISO/IEC 13816:1997(E), revised to ISO/IEC 13816:2007(E)..

Zonnon is a programming language along the Oberon, Modula, and Pascal language line. Jürg Gutknecht is the author of the programming language.


  1. Summary of Projects by N. Wirth, 1962–1999
  2. N. Wirth, "Pascal and its Successors". Software Pioneers, M. Broy and E. Denert, Eds. Springer-Verlag, 2002, ISBN   3-540-43081-4
  3. Niklaus Wirth, "History and Goals od Modula-2". Dr. Dobbs, 2005
  4. N. Wirth, Programming in Modula-2, fourth Edition, page 4.
  5. BYTE – The Small Systems Journal, 1984 (8), pp. 143–232. Available at
  6. Wirth, N. (1 May 1984). "A Single-pass Modula-2 Compiler for Lilith" (PDF). Retrieved 28 January 2019.
  7. ISO/IEC 10514-1:1996
  8. Tichy et al., Modula-2*: An Extension for Modula-2 for highly parallel portable programs, University of Karlsruhe [1990]
  9. Bräunl, Parallel Programming, Prentice-Hall [1993]
  10. Muller, C. Modula--Prolog: A Software Development (1986) IEEE Software
  11., 5. Where can I get information about ISO Modula-2?,
  12., 5. Where can I get information about ISO Modula-2?,
  13. Cardelli et al., Modula-3 Report, Research Report 31, Systems Research Center, Digital Equipment Corporation, [1988]
  14. N. Wirth & J. Gutknecht, Project Oberon: the design of an operating system and compiler, ISBN   0-201-54428-8, Addison-Wesley [1992]
  15. Moessenboeck & Wirth, The Programming Language Oberon-2, ETH Zurich [1995]
  16. Thomas Bräunl, Parallaxis, a Language for Structured Data-parallel Programming, University of Stuttgart [1996]
  17. Pat D. Terry, Another Minimal Programming Language, ACM SIGPLAN Notices No. 30 [1995]
  18. D. Blasband, The YAFL Programming Language, Second Edition, [1993]
  19. Delco Electronics Electron Magazine, The Atwood Legacy, Spring '89, page 25
  20. Development of electronics for GM auto racing

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.