SRC Modula-3
An Elegant, Free, Open, Mature, High-Quality, Clean & Modest
Programming Language, System, Library & Tool
for Building Robust, Large-Scale, Multi-Threaded & Distributed Programs

Farshad Nayeri
Cambridge, Massachusetts, USA.
Revised: 1 April 1996.

Abstract

Despite its length and buzzword density, the subtitle above is one the shortest phrases that characterize the virtues of SRC Modula-3. The language designers' stated goal of "consolidation, not innovation" is a modest understatement for their wise, elegant, and inventive combination of features that are greatly needed by the modern programmer. Freely available in source and binary forms, SRC Modula-3 comes with a library of more than 1500 interfaces that run on 12 hardware platforms and 25 operating systems--- all without #ifdef's. The libraries and tools support much of what you might expect from a solid programming language and more: from run-time types to portable operating system interfaces, from safe interfaces to TCP to distributed and persistent object systems, from animations to projective geometry, from X11 integration to OpenGL interfaces.

With a royalty-free and open distribution license that is clearly designed to promote its use, adoption, and redistribution by others, SRC Modula-3 makes a great environment for both professional and academic development. The author has been a happy user of SRC Modula-3 for the past 4 years and is amazed that a system so well-designed (with a price so right) is not being used more often. Hence, he is paying his dues by promoting SRC Modula-3.

Introduction

My first impression of the language --- back when I learned about it in 1989 --- was that it had elegantly combined the simplicity of Pascal with the power of C. Then I got lucky enough to use it for systems development for a few years. As I learned more about language design and implementation trade-offs, I came to the realization that I had underestimated the design's virtues in my initial evaluation. I learned how Modula-3 mixes proven features for robust programming with sheer elegance: garbage collection and closures from Lisp, objects from Simula and Smalltalk, threads from Mesa and Cedar, exceptions and abstractions from Clu, generics from Ada, modules from Modula-2, simplicity from Pascal, and minimality and efficiency from C. It tops off these features with such novel concepts as strict isolation of safe and unsafe code, and a powerful type system that supports layered abstractions and structural equivalence, all absent from other languages of its class. Despite all this, I am happy to say that Modula-3 is quite immune to featuritis! Its concise 50-page language definition puts as much care into supporting the programmer as making sure that an efficient implementation can be built without too much effort.

Of course, all of this would be considered "academic" if it weren't for the case that, for the past 6 years or so, Digital Systems Research Center (SRC) has been building a highly portable implementation of the language, the run-time and the library, and releasing their sources on the Internet to be used free of charge. Having released the compiler, run-time, libraries and tools, SRC went on to coordinate porting efforts to new and old operating systems, track bugs, and advance the state of the compiler, the run-time system, and its high-quality libraries. Of course, all of this would have been impossible without the help of many volunteers on the Internet.

Just the Facts, Ma'am

You may ask: What do I get with SRC Modula-3? The short answer is: a very full hard disk! Unfortunately the long answer goes well beyond a couple of pages of description. I will do my best to summarize.

The language --- in its 50 page definition --- comes standard with support for strong types, garbage collection, modules and interfaces, portable threads, exceptions, isolation of safe and unsafe code, objects with single inheritance, run-time type identification, and generics.

The SRC compiler generates native code and has an open back-end. Two families of code generators have been implemented: a portable back-end that generates gcc parse-trees, and a fast "integrated" back-end that directly generates code with "Turbo-Pascal-like" speed on Linux and Windows. Originally the back-end generated C, but a few years ago it was abandoned in favor of native compilation.

The builder performs minimal re-compilation. Only those units that depend on a modified item will be recompiled (no more hour-long compiles because you decided to add a comment line in a common interface). The builder uses declarative descriptions simpler and more portable than make's operational style.

Two garbage collectors are supported: a virtual-memory-based, multi-threaded, incremental, conservative garbage collector, and a simple stop-and-copy collector to ease porting.

Modula-3 comes with a large and well-documented standard library, which supports the same interface across various flavors of Unix, NT, and Win/95. All standard library modules are thread-safe, and in many cases thread-friendly, and make consistent use of garbage collection and exception-handling. The portable libraries include string manipulation; generic containers such as sequences, lists, tables, and sets; Lisp-like atoms and symbolic expressions; an extensible thread-friendly I/O stream system with file, memory, and network streams; persistent "pickled" objects; and portable operating system interfaces that look the same everywhere.

A key package in the SRC distribution is Network Objects. A state-of-the-art distributed object system, Network Objects eases the development of multi-threaded distributed applications, and is one of the few distributed object systems today that provides a practical distributed garbage collector. It is, in many ways, nicer than the equivalent CORBA systems costing thousands of dollars.

Trestle, a multi-threaded window system written in Modula-3, relieves the programmer of event-loop hassles. Having been ported to both X11 and Win32, Trestle comes with a large array of widgets and user interface creation tools.

Finally, because Modula-3 provides for restricted use of unsafe operations, you can link your code with "legacy" C code readily. In fact, many popular C libraries, such as X11, Win32, OpenGL, Tcl, and TCP, are bound to Modula-3 interfaces already. Calling Modula-3 from C is also generally straightforward.

Conclusion

If you are:

then you are in luck: SRC Modula-3 is here for you!

Reference

Modula-3 Home Page: http://www.research.digital.com/SRC/modula-3/html/ (where you will be able to find a link to the electronic version of this document.)