Description #
Modula-2 is a structured, statically typed compiled language designed for modular and systems programming. It introduced the concept of modules as first-class language elements, emphasizing strong type safety and code organization.
History #
Modula-2 was developed by Niklaus Wirth in 1977 as the successor to Pascal and a precursor to Oberon. It was originally created to support the development of the Lilith workstation at ETH Zurich. Modula-2 introduced clearer separation of interface and implementation code via the module system, influencing future languages such as Ada and Python.
Hello World Code #
MODULE HelloWorld;
FROM InOut IMPORT WriteLn, WriteString;
BEGIN
WriteString("Hello, World!");
WriteLn;
END HelloWorld.
How to Run #
Option 1: Online
https://www.tutorialspoint.com/compile_modula2_online.php
Option 2: Local
- Install the GNU Modula-2 compiler:
https://modula2.org/gnm2/ - Compile and run: bashCopyEdit
gm2 hello.mod ./a.out
Key Concepts #
- Syntax style: Pascal-like, structured
- Typing discipline: Strong, static
- Execution model: Compiled to native machine code
- Common use cases: Embedded systems, teaching, operating systems
- Toolchain or ecosystem: GNU Modula-2, Gardens Point Modula-2
- Paradigms supported: Procedural, modular
- Compilation details: Interface and implementation files compiled separately
- Strengths or quirks: Built-in module system, simple concurrency via coroutines
- Libraries/frameworks: Limited to system-level modules and utilities
- Community/adoption: Mostly academic, with some hobbyist and legacy users
Try It Online #
https://www.tutorialspoint.com/compile_modula2_online.php
Fun Facts #
Modula-2 was used to teach programming and system design in universities throughout the 1980s. Its modular design philosophy has had a lasting influence on many mainstream languages.