Modula-2 was designed by Niklaus Wirth at ETH Zurich around 1978, with the first compiler running in 1979. To understand Niklaus Wirth's Modula-2 and the Lilith workstation, you need to know that the language and the machine were built together: Wirth wanted a single, safe, structured language that could be used for everything on a personal workstation, from the operating system kernel and device drivers to the text editor and compiler.

Niklaus Wirth's Modula-2 and the Lilith workstation

Wirth had already designed Pascal in 1970, a language aimed at teaching, and Modula in the mid-1970s, an experiment in multiprogramming. In 1976 and 1977 he spent a sabbatical at Xerox PARC, where he saw the Alto workstation and the Mesa language, which had modules with separate interfaces and implementations. He came back to Zurich determined to build something similar on a smaller budget.

The result was the Lilith, a workstation with a bitmapped display and a mouse, designed at ETH and running around 1980. Its microcode interpreted M-code, a compact instruction set tailored to Modula-2. The operating system, Medos-2, the compiler, the editor and the tools were all written in Modula-2. Wirth's book Programming in Modula-2 appeared in 1982 and went through several editions, each describing slightly different revisions of the language.

Design and key features

Modula-2 kept Pascal's clear syntax but fixed many of the things that made Pascal awkward for systems work.

  • Modules are the central idea. A definition module declares what is exported; an implementation module contains the code. They can be compiled separately, with the compiler checking interfaces.
  • Opaque types let a module hide the structure of a type, giving real information hiding.
  • Low-level access through a SYSTEM module with types like ADDRESS and WORD, clearly marked as unsafe.
  • Coroutines for concurrency, used to write process schedulers in the language itself.
  • Procedure types, so procedures can be stored in variables and passed around.
  • Cleaner syntax than Pascal: every structured statement ends with END, removing the need for many BEGIN blocks.
  • Case-sensitive identifiers and reserved words in capitals.
DEFINITION MODULE Stack;
  PROCEDURE Push(x: INTEGER);
  PROCEDURE Pop(): INTEGER;
  PROCEDURE Empty(): BOOLEAN;
END Stack.

IMPLEMENTATION MODULE Stack;
  CONST Max = 100;
  VAR data: ARRAY [1..Max] OF INTEGER;
      top: CARDINAL;

  PROCEDURE Push(x: INTEGER);
  BEGIN
    INC(top); data[top] := x
  END Push;

  PROCEDURE Pop(): INTEGER;
  BEGIN
    DEC(top); RETURN data[top + 1]
  END Pop;

  PROCEDURE Empty(): BOOLEAN;
  BEGIN
    RETURN top = 0
  END Empty;

BEGIN
  top := 0
END Stack.

Client code only sees the definition module. The array and the top counter are invisible outside, and the statements after the final BEGIN run once to initialise the module.

Compilers, the ISO standard and commercial use

YearMilestone
1978Language designed at ETH Zurich
1979First compiler (on a PDP-11)
around 1980Lilith workstation running Medos-2
1982Programming in Modula-2 published
1996ISO/IEC 10514-1 standard
2023GNU Modula-2 included in GCC 13

In the 1980s Modula-2 became popular on personal computers. Logitech sold a Modula-2 development system for the PC, and later JPI's TopSpeed Modula-2 was well regarded. Compilers existed for the Amiga, Atari ST and Macintosh. Many universities used Modula-2 as their teaching language after Pascal. It was also used for embedded and control software; the Russian GLONASS satellite navigation system is often reported as one example.

Influence and legacy

Modula-2's ideas had a long reach. Wirth's next language, Oberon (1987), simplified it further and added type extension. DEC and Olivetti designed Modula-3 from it, which in turn influenced Java and Python's module and exception design. The idea of separately compiled interfaces with strict checking appears in Ada packages and, much later, in Go's packages; Go's designers have cited the Pascal, Modula and Oberon lineage directly. Wirth received the Turing Award in 1984 and died in January 2024.

Is Modula-2 still used today?

Only in small numbers. It survives in legacy industrial and embedded systems, in a few teaching settings, and through GNU Modula-2, which brought the language back into mainstream compiler distribution with GCC 13. Looking at Niklaus Wirth's Modula-2 and the Lilith workstation together shows why the language mattered: it proved that one strongly typed, modular language could carry an entire computer, from microcode-level drivers to the user interface.

Frequently asked questions

What is the difference between Pascal and Modula-2?

Modula-2 adds modules with separate definition and implementation parts, opaque types, coroutines and controlled low-level access, all of which standard Pascal lacked. Its syntax is also tidier, since structured statements end with END. Pascal was designed for teaching; Modula-2 was designed for building whole systems.

What was the Lilith computer used for?

Lilith was a personal workstation developed at ETH Zurich around 1980, inspired by the Xerox Alto. It was used for research, teaching and document preparation at ETH, and it showed that a complete operating system and toolset could be written in Modula-2. A small number of machines were also produced commercially.

Can I still compile Modula-2 code today?

Yes. GNU Modula-2 is part of GCC since version 13 and supports the PIM dialects and ISO Modula-2. Other options include the ADW Modula-2 compiler for Windows and several open source projects that target modern systems.