Description #
Modula-2 is a statically typed, procedural programming language designed for system and application programming. It emphasizes modular programming with strong type safety and supports structured programming concepts.
History #
Developed by Niklaus Wirth in the late 1970s as a successor to Pascal, Modula-2 introduced modules to facilitate separate compilation and code reuse. It was widely used in academia and embedded systems and influenced later languages like Oberon.
Hello World Code #
MODULE HelloWorld;
FROM InOut IMPORT WriteString, WriteLn;
BEGIN
WriteString("Hello, World!");
WriteLn;
END HelloWorld.
How to Run #
Option 1: Online
Use online compilers like OnlineGDB Modula-2.
Option 2: Local
- Install a Modula-2 compiler like GNU Modula-2 or XDS
- Compile and run:
m2c hello.mod
./hello
Key Concepts #
- Strong, static typing with module support
- Designed for systems and embedded programming
- Supports separate compilation via modules
- Syntax derived from Pascal with enhancements
- Structured programming with control flow constructs
- Efficient and predictable performance
- Minimal runtime environment
- Widely used in teaching programming concepts
- Influenced later languages (Oberon, Ada)
- Supports low-level system access
Try It Online #
Fun Facts #
- Modula-2 introduced the concept of modules that influenced modern software design.
- It was designed by the same author as Pascal, Niklaus Wirth.
- Modula-2’s modular system helps manage large codebases effectively.
- The language was popular in the 1980s and 1990s in education and industry.
- Modula-2’s influence is visible in languages like Ada and Oberon.