Florida Tech, CIS: Programming Languages (Spring 99)


WWW Project on MODULA-3 by Krishnapal Chhabra

Instructor

Ryan Stansifer, contact info at http://www.cs.fit.edu/~ryan , e-mail address ryan@cs.fit.edu

In this Project, I have created a WWW page conataining information about the Modula-3 programming language and a simple Java applet.

Introduction

Modula-3 is a systems programming language that descends from Mesa,Modula-2, Cedar, and Modula-2+. It also resembles its cousins Object Pascal, Oberon, and Euclid.Modula-3 is a member of the Pascal/Modula family of languages. Despite its name, Modula-3 is much more than just another successor to Modula-2.

The goal of Modula-3 is to be as simple and safe as it can be while meeting the needs of modern systems programmers. Instead of exploring new untried features, the designers followed proven practice. The language features that depart from previous designs aimed at two important areas: a simpler type system and greater robustness.

Modula-3 retains Modula-2's module system for the most part and most of its Pascal-like syntactic style. It adds objects, exception handling, garbage collection, lightweight processes (also called threads), generics, and the ability to separate safe and unsafe code, all in one integrated whole. The combination of features in Modula-3 makes it both a wonderful systems programming language and a great teaching language.

Is Modula-3 a superset of Modula-2?
No; valid Modula-2 programs are not valid Modula-3 programs. However, there is a tool to help convert Modula-2 programs to Modula-3.

Features:

This is an overview of the most important features of Modula-3.
  • Interfaces

  • One of Modula-2's most successful features is the provision for explicit interfaces between modules. Interfaces are retained with essentially no changes in Modula-3. A module imports the interfaces it depends on and exports the interface (or, in Modula-3, the interfaces) that it implements.
  • Objects

  • Objects in Modula-3 are very much like objects in Simula: they are always references, they have both data fields and methods, and they have single inheritance but not multiple inheritance.
    In Modula-3 the main design effort is concentrated into specifying the properties of a single abstract type---a stream of characters, a window on the screen. Then dozens of interfaces and modules are coded that provide useful subtypes of the central abstraction.
    Modula-3 provides two separate mechanisms for data-hiding: one for hiding details about how interfaces are implemented, and the other for hiding details about how objects are implemented.
  • Generics

  • A generic module is a template in which some of the imported interfaces are regarded as formal parameters, to be bound to actual interfaces when the generic is instantiated.
    To keep Modula-3 generics simple, they are confined to the module level: generic procedures and types do not exist in isolation, and generic parameters must be entire interfaces.
  • Threads

  • The provisions for threads in Modula-2 are weak, amounting essentially to coroutines. Modula-3 has good provisions for threads.
  • Safety

  • The languages of the BCPL family are full of unsafe features; the languages of the Lisp family generally have none (or none that are documented). In this area Modula-3 follows the lead of Cedar by adopting a small number of unsafe features that are allowed only in modules explicitly labeled unsafe. In a safe module, the compiler prevents any errors that could corrupt the runtime system; in an unsafe module, it is the programmer's responsibility to avoid them.
  • Garbage Collection

  • Modula-3 provides "traced references", which are like Modula-2 pointers except that the storage they point to is kept in the "traced heap" where it will be freed automatically when all references to it are gone.
    For programs that cannot afford garbage collection, Modula-3 provides a set of reference types that are not traced by the garbage collector. In most other respects, traced and untraced references behave identically.
  • Exceptions

  • An exception is a control construct that exits many scopes at once. Raising an exception exits active scopes repeatedly until a handler is found for the exception, and transfers control to the handler. If there is no handler, the computation terminates in some system-dependent way---for example, by entering the debugger.
  • Type system

  • Like all languages in the Algol family, Modula-3 is strongly typed. The basic idea of strong typing is to partition the value space into types, restrict variables to hold values of a single type, and restrict operations to apply to operands of fixed types. They have adopted several principles in order to make Modula-3's type system as uniform as possible.
  • Simplicity

  • In the early days of the Ada project, a general in the Ada Program Office opined that "obviously the Department of Defense is not interested in an artificially simplified language such as Pascal". Modula-3 represents the opposite point of view. We used every artifice that we could find or invent to make the language simple.

    Resources

  • Yahoo's Programming Languages

  • Design History

  • Language Definition

  • FAQs

  • Concise Bibliography

  • Modula-3 at Work

  • Modula-3 Home Page

  • Related Sites

  • References and Tutorials


  • Modula-3 Reference and Tutorial

  • Programming with Threads in Modula-3 a Newsletter

  • Tutorials, books, and articles

  • Trestle by example

  • Network Objects

  • Online bookstores for Modula-3 references


  • Comments & Suggestuins
    kchhabra@zach.fit.edu