Modula-3
Encyclopedia
In computer science
, Modula-3 is a programming language
conceived as a successor to an upgraded version of Modula-2
known as Modula-2+
. While it has been influential in research circles (influencing the designs of languages such as Java
, C#, and Python
) it has not been adopted widely in industry. It was designed by Luca Cardelli
, James Donahue, Lucille Glassman, Mick Jordan (before at the Olivetti
Software Technology Laboratory), Bill Kalsow and Greg Nelson at the Digital Equipment Corporation (DEC
) Systems Research Center
(SRC) and the Olivetti
Research Center (ORC) in the late 1980s.
Modula-3's main features are simplicity and safety while preserving the power of a systems-programming language. Modula-3 aimed to continue the Pascal
tradition of type safety, while introducing new constructs for practical real-world programming. In particular Modula-3 added support for generic programming
(similar to templates
), multithreading
, exception handling
, garbage collection
, object-oriented programming
, partial revelation and explicit mark of unsafe code.
The design goal of Modula-3 was a language that implements the most important features of modern imperative
languages in quite basic forms. Thus allegedly dangerous and complicating features like multiple inheritance
and operator overloading
were omitted.
with some ideas for a new version of Modula. Wilkes had been working at DEC just prior to this point, and had returned to England and joined Olivetti's Research Strategy Board. Wirth had already moved on to Oberon
, but had no problems with Wilkes's team continuing development under the Modula name. The language definition was completed in August 1988, and an updated version in January 1989. Compilers from DEC and Olivetti soon followed, and 3rd party implementations after that.
Its design was heavily influenced by work on the Modula-2+
language in use at SRC and at the Acorn Computers
Research Center (ARC, later ORC when Olivetti bought out Acorn) at the time, which was the language in which the operating system for the DEC Firefly
multiprocessor VAX
workstation was written and in which the Acorn
Compiler for Acorn Modula-2 Extended Language (CAMEL) at ARC for the ARX operating system
project of ARM
based Acorn Archimedes
range of computers were written. As the revised Modula-3 Report states, the language was influenced by other languages such as Mesa, Cedar, Object Pascal
, Oberon
and Euclid.
During the 1990s, Modula-3 gained considerable currency as a teaching language, but it was never widely adopted for industrial use. Contributing to this may have been the demise of DEC, a key Modula-3 supporter (specially when it ceased to maintain it effectively any more before DEC was sold to Compaq
in 1998). In any case, in spite of Modula-3's simplicity and power, it appears that there was little demand for a procedural compiled language
with restricted implementation of object-oriented programming
. For a time, a commercial compiler
called CM3 maintained by one of the chief implementors prior at DEC SRC who was hired before DEC being sold to Compaq
, an integrated development environment
called Reactor and an extensible Java Virtual Machine
(licensed in binary and source formats and buildable with Reactor) were offered by Critical Mass, Inc., but that company ceased active operations in 2000 and gave some of the sources of its products to elego Software Solutions GmbH
. Modula-3 is now taught in universities mostly in comparative programming language courses, and its textbooks are out of print. Essentially the only corporate supporter of Modula-3 is elego Software Solutions GmbH, which inherited the sources from Critical Mass and has since made several releases of the CM3 system in source and binary form. The Reactor IDE has been open source released after several years it had not, with the new name CM3-IDE. In March 2002 elego also took over the repository of another active Modula-3 distribution, PM3, till then maintained at the École Polytechnique de Montréal
but which later continued by the work on HM3 improved over the years later until it was obsoleted.
is the Hello world program
.
All programs in Modula-3 have at least a module file, while most also include an interface file that is used by clients to access data from the module. Like in other languages, a Modula-3 program must export a Main module, which can either be a file named Main.m3, or a file can call
Module file names are suggested to be the same as the actual module name, but the compiler will only warn you if they are different.
Other conventions in the syntax include naming the exported type of an interface
An interface compilation unit, beginning with the keyword
defines constants, types, variables, exceptions, and procedures.
The implementation module, beginning with the keyword
any further constants, types, or variables needed to implement the interface.
By default an implementation module will implement the interface of the same name,
but a module may explicitly
For example, the main program exports an implementation module for the Main interface.
Any compilation unit may
the items contained in the interface.
Typically, one only imports the interface, and uses the 'dot' notation to access the items within the interface
(similar to accessing the fields within a record).
A typical usage is to define one data structure (record or object) per interface along with any support procedures.
Here the main type will get the name 'T', and one uses as in MyModule.T.
).
The keyword
For example, an unsafe operation is bypassing the type system using
An interface that imports an unsafe module must itself be unsafe.
A safe interface may be exported by an unsafe implementation module.
This is the typical usage when interfacing to external libraries,
where two interfaces are built (one unsafe, the other safe).
prefix the
and take as formal arguments other interfaces.
Thus (like C++ templates) one can easily define and use abstract data types,
but unlike C++, the granularity is at the module level.
For example, one could define a GenericStack, then instantiate it with an
An interface module would be passed to the generic interface and implementation modules as actual arguments, and the
compiler will generate concrete modules.
A compilation unit must import identifiers from other compilation units, using an
Even enumerations make use of the same 'dot' notation as used when accessing a field of a record.
There are two kinds of memory that can be allocated
The difference being if the garbage collector
can see it or not.
NEW is used to allocate data of either of these classes of memory.
In an
Object support is intentionally kept to its simplest terms.
An object type (Termed a "class" in other object oriented languages) is introduced with the
which has essentially the same syntax as a
although an object type is a reference type, whereas RECORDs in Modula-3 are not (similar to structs in C).
Exported types are usually named T by convention, and create a separate "Public" type to expose the methods and data.
For instance:
This defines an interface
To create a new
Modula-3's
We use
Note the use of the
Modula-3 is one of the few programming languages that requires that external references from a
module be strictly qualified. That is, a reference in module
possible in Modula-3 to import "all exported names" from a module.
Because of the language's requirements on name qualification and method overriding, it is impossible to break a working program simply by adding new declarations to an interface (any interface). This makes it possible for large programs to be edited concurrently by many programmers without any worries about naming conflicts; and it also makes it possible to edit core language libraries with the firm knowledge that no existing programs will be "broken" in the process.
handling is based on a
http://www.python.org/doc/faq/general/#why-was-python-created-in-the-first-place, Scalahttp://scala.epfl.ch and Visual Basic.NET, is that the
The
The Modula-3 runtime may make use of a separate thread for garbage collection.
There is a standard module within the runtime library (libm3) named Thread,
which supports the use of multi-threaded applications.
Modula-3 is one of the rare languages whose evolution of features is documented.
In Systems Programming with Modula-3, four essential points of the language design are intensively discussed. These topics are: structural vs. name equivalence, subtyping rules, generic modules, and parameter modes like
programming language, many of the features required to write real programs were left out of the language definition itself and instead provided via a number of standard libraries. Most of the interfaces below are described in detail in
Standard libraries providing the following features. This are called standard interfaces and are required (must be provided) in the language.
Some recommended interfaces implemented in the available implementations but are not required
As in C, I/O is also provided via libraries, in Modula-3 called
) and Extended Static Checking
projects at DEC Systems Research Center.
.
Since the only aspect of C data structures that is missing from Modula-3 is the
union type, all existing Modula-3 implementations are able to provide good binary compatibility with C language type declarations of arrays and structs.
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...
, Modula-3 is a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
conceived as a successor to an upgraded version of Modula-2
Modula-2
Modula-2 is a computer programming language designed and developed between 1977 and 1980 by Niklaus Wirth at ETH Zurich as a revision of Pascal to serve as the sole programming language for the operating system and application software for the personal workstation Lilith...
known as Modula-2+
Modula-2+
Modula-2+ is a programming language descended from the Modula-2 language. It was developed at DEC Systems Research Center and Acorn Computers Ltd Research Centre in Palo Alto, California. Modula-2+ is Modula-2 with exceptions and threads. The group who developed the language was led by P...
. While it has been influential in research circles (influencing the designs of languages such as Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
, C#, and Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
) it has not been adopted widely in industry. It was designed by Luca Cardelli
Luca Cardelli
Luca Cardelli is an Italian computer scientist who is currently an Assistant Director at Microsoft Research in Cambridge, UK. Cardelli is well-known for his research in type theory and operational semantics. Among other contributions he implemented the first compiler for the functional programming...
, James Donahue, Lucille Glassman, Mick Jordan (before at the Olivetti
Olivetti
Olivetti S.p.A. is an Italian manufacturer of computers, printers and other business machines.- Founding :The company was founded as a typewriter manufacturer in 1908 in Ivrea, near Turin, by Camillo Olivetti. The firm was mainly developed by his son Adriano Olivetti...
Software Technology Laboratory), Bill Kalsow and Greg Nelson at the Digital Equipment Corporation (DEC
Digital Equipment Corporation
Digital Equipment Corporation was a major American company in the computer industry and a leading vendor of computer systems, software and peripherals from the 1960s to the 1990s...
) Systems Research Center
DEC Systems Research Center
The Systems Research Center was a research laboratory created by Digital Equipment Corporation in 1984, in Palo Alto, California....
(SRC) and the Olivetti
Olivetti
Olivetti S.p.A. is an Italian manufacturer of computers, printers and other business machines.- Founding :The company was founded as a typewriter manufacturer in 1908 in Ivrea, near Turin, by Camillo Olivetti. The firm was mainly developed by his son Adriano Olivetti...
Research Center (ORC) in the late 1980s.
Modula-3's main features are simplicity and safety while preserving the power of a systems-programming language. Modula-3 aimed to continue the Pascal
Pascal (programming language)
Pascal is an influential imperative and procedural programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small and efficient language intended to encourage good programming practices using structured programming and data structuring.A derivative known as Object Pascal...
tradition of type safety, while introducing new constructs for practical real-world programming. In particular Modula-3 added support for generic programming
Generic programming
In a broad definition, generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters...
(similar to templates
Template (programming)
Templates are a feature of the C++ programming language that allow functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one....
), multithreading
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
, exception handling
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....
, garbage collection
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...
, object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
, partial revelation and explicit mark of unsafe code.
The design goal of Modula-3 was a language that implements the most important features of modern imperative
Imperative programming
In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state...
languages in quite basic forms. Thus allegedly dangerous and complicating features like multiple inheritance
Multiple inheritance
Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass....
and operator overloading
Operator overloading
In object oriented computer programming, operator overloading—less commonly known as operator ad-hoc polymorphism—is a specific case of polymorphism, where different operators have different implementations depending on their arguments...
were omitted.
Historical development
The Modula-3 project started in November 1986 when Maurice Wilkes wrote to Niklaus WirthNiklaus Wirth
Niklaus Emil Wirth is a Swiss computer scientist, best known for designing several programming languages, including Pascal, and for pioneering several classic topics in software engineering. In 1984 he won the Turing Award for developing a sequence of innovative computer languages.-Biography:Wirth...
with some ideas for a new version of Modula. Wilkes had been working at DEC just prior to this point, and had returned to England and joined Olivetti's Research Strategy Board. Wirth had already moved on to Oberon
Oberon (programming language)
Oberon is a programming language created in 1986 by Professor Niklaus Wirth and his associates at ETH Zurich in Switzerland. It was developed as part of the implementation of the Oberon operating system...
, but had no problems with Wilkes's team continuing development under the Modula name. The language definition was completed in August 1988, and an updated version in January 1989. Compilers from DEC and Olivetti soon followed, and 3rd party implementations after that.
Its design was heavily influenced by work on the Modula-2+
Modula-2+
Modula-2+ is a programming language descended from the Modula-2 language. It was developed at DEC Systems Research Center and Acorn Computers Ltd Research Centre in Palo Alto, California. Modula-2+ is Modula-2 with exceptions and threads. The group who developed the language was led by P...
language in use at SRC and at the Acorn Computers
Acorn Computers
Acorn Computers Ltd. was a British computer company established in Cambridge, England, in 1978. The company produced a number of computers which were especially popular in the UK. These included the Acorn Electron, the BBC Micro, and the Acorn Archimedes...
Research Center (ARC, later ORC when Olivetti bought out Acorn) at the time, which was the language in which the operating system for the DEC Firefly
DEC Firefly
The Firefly was a shared memory asymmetric multiprocessor workstation, developed by the Systems Research Center, a research organization within Digital Equipment Corporation. The first version built contained up to seven MicroVAX 78032 microprocessors...
multiprocessor VAX
VAX
VAX was an instruction set architecture developed by Digital Equipment Corporation in the mid-1970s. A 32-bit complex instruction set computer ISA, it was designed to extend or replace DEC's various Programmed Data Processor ISAs...
workstation was written and in which the Acorn
Acorn Computers
Acorn Computers Ltd. was a British computer company established in Cambridge, England, in 1978. The company produced a number of computers which were especially popular in the UK. These included the Acorn Electron, the BBC Micro, and the Acorn Archimedes...
Compiler for Acorn Modula-2 Extended Language (CAMEL) at ARC for the ARX operating system
ARX (operating system)
ARX was a Mach-like operating system written in Modula-2+ developed by Acorn Computers Ltd in the UK and the Acorn Research Centre and Software Technology Laboratory and later Olivetti Research Center at Palo Alto for their new ARM RISC processors based Archimedes computers range...
project of ARM
ARM architecture
ARM is a 32-bit reduced instruction set computer instruction set architecture developed by ARM Holdings. It was named the Advanced RISC Machine, and before that, the Acorn RISC Machine. The ARM architecture is the most widely used 32-bit ISA in numbers produced...
based Acorn Archimedes
Acorn Archimedes
The Acorn Archimedes was Acorn Computers Ltd's first general purpose home computer to be based on their own ARM architecture.Using a RISC design with a 32-bit CPU, at its launch in June 1987, the Archimedes was stated as running at 4 MIPS, with a claim of 18 MIPS during tests.The name is commonly...
range of computers were written. As the revised Modula-3 Report states, the language was influenced by other languages such as Mesa, Cedar, Object Pascal
Object Pascal
Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Embarcadero Delphi.-Early history at Apple:...
, Oberon
Oberon (programming language)
Oberon is a programming language created in 1986 by Professor Niklaus Wirth and his associates at ETH Zurich in Switzerland. It was developed as part of the implementation of the Oberon operating system...
and Euclid.
During the 1990s, Modula-3 gained considerable currency as a teaching language, but it was never widely adopted for industrial use. Contributing to this may have been the demise of DEC, a key Modula-3 supporter (specially when it ceased to maintain it effectively any more before DEC was sold to Compaq
Compaq
Compaq Computer Corporation is a personal computer company founded in 1982. Once the largest supplier of personal computing systems in the world, Compaq existed as an independent corporation until 2002, when it was acquired for US$25 billion by Hewlett-Packard....
in 1998). In any case, in spite of Modula-3's simplicity and power, it appears that there was little demand for a procedural compiled language
Compiled language
A compiled language is a programming language whose implementations are typically compilers , and not interpreters ....
with restricted implementation of object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
. For a time, a commercial compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
called CM3 maintained by one of the chief implementors prior at DEC SRC who was hired before DEC being sold to Compaq
Compaq
Compaq Computer Corporation is a personal computer company founded in 1982. Once the largest supplier of personal computing systems in the world, Compaq existed as an independent corporation until 2002, when it was acquired for US$25 billion by Hewlett-Packard....
, an integrated development environment
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...
called Reactor and an extensible Java Virtual Machine
Java Virtual Machine
A Java virtual machine is a virtual machine capable of executing Java bytecode. It is the code execution component of the Java software platform. Sun Microsystems stated that there are over 4.5 billion JVM-enabled devices.-Overview:...
(licensed in binary and source formats and buildable with Reactor) were offered by Critical Mass, Inc., but that company ceased active operations in 2000 and gave some of the sources of its products to elego Software Solutions GmbH
Elego Software Solutions GmbH
elego Software Solutions GmbHelego is a software development and consulting firm based in Berlin, Germany. The company specializes in Software Configuration Management and Application Lifecycle Management ....
. Modula-3 is now taught in universities mostly in comparative programming language courses, and its textbooks are out of print. Essentially the only corporate supporter of Modula-3 is elego Software Solutions GmbH, which inherited the sources from Critical Mass and has since made several releases of the CM3 system in source and binary form. The Reactor IDE has been open source released after several years it had not, with the new name CM3-IDE. In March 2002 elego also took over the repository of another active Modula-3 distribution, PM3, till then maintained at the École Polytechnique de Montréal
École Polytechnique de Montréal
The École Polytechnique de Montréal is an engineering school/faculty affiliated with the University of Montreal in Montreal, Canada. It ranks first in Canada for the scope of its engineering research. It is occasionally referred to as Montreal Polytechnic, although in Quebec English its French...
but which later continued by the work on HM3 improved over the years later until it was obsoleted.
Syntax
A common example of a language's syntaxSyntax
In linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....
is the Hello world program
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...
.
All programs in Modula-3 have at least a module file, while most also include an interface file that is used by clients to access data from the module. Like in other languages, a Modula-3 program must export a Main module, which can either be a file named Main.m3, or a file can call
EXPORT
to export the Main module.Module file names are suggested to be the same as the actual module name, but the compiler will only warn you if they are different.
Other conventions in the syntax include naming the exported type of an interface
T
, since types are usually qualified by their full names, so a type T
inside a module named Foo will be named Foo.T
. This aides in readability. Another similar convention is naming a public object Public
as in the OOP examples above.Modularity
First and foremost, all compilation units are eitherINTERFACE
or implementation MODULE
s, of one flavor or another.An interface compilation unit, beginning with the keyword
INTERFACE
,defines constants, types, variables, exceptions, and procedures.
The implementation module, beginning with the keyword
MODULE
, provides the actual code, andany further constants, types, or variables needed to implement the interface.
By default an implementation module will implement the interface of the same name,
but a module may explicitly
EXPORT
to a module not of the same name.For example, the main program exports an implementation module for the Main interface.
Any compilation unit may
IMPORT
other interfaces, and under programer control,the items contained in the interface.
Typically, one only imports the interface, and uses the 'dot' notation to access the items within the interface
(similar to accessing the fields within a record).
A typical usage is to define one data structure (record or object) per interface along with any support procedures.
Here the main type will get the name 'T', and one uses as in MyModule.T.
Safe vs Unsafe
Some capability is deemed unsafe, where the compiler can no longer guarantee the results will be consistent (for example, when interfacing to the C programming languageC (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
).
The keyword
UNSAFE
prefixed in front of INTERFACE
or MODULE
, may be used to tell the compiler to enable certain low level features of the language.For example, an unsafe operation is bypassing the type system using
LOOPHOLE
to copy the bits of an integer into a floating point REAL
number.An interface that imports an unsafe module must itself be unsafe.
A safe interface may be exported by an unsafe implementation module.
This is the typical usage when interfacing to external libraries,
where two interfaces are built (one unsafe, the other safe).
Generics
A generic interface and its corresponding generic module,prefix the
INTERFACE
or MODULE
keyword with GENERIC
,and take as formal arguments other interfaces.
Thus (like C++ templates) one can easily define and use abstract data types,
but unlike C++, the granularity is at the module level.
For example, one could define a GenericStack, then instantiate it with an
INTEGER
, REAL
, or even references to Objects.An interface module would be passed to the generic interface and implementation modules as actual arguments, and the
compiler will generate concrete modules.
Tracability
Any identifier can be traced back to where it originated, unlike the 'include' feature of other languages.A compilation unit must import identifiers from other compilation units, using an
IMPORT
statement.Even enumerations make use of the same 'dot' notation as used when accessing a field of a record.
Dynamic Programming
Modula-3 supports the allocation of data at runtime.There are two kinds of memory that can be allocated
TRACED
and UNTRACED
.The difference being if the garbage collector
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...
can see it or not.
NEW is used to allocate data of either of these classes of memory.
In an
UNSAFE
module, DISPOSE
is available to free untraced memory.Object Oriented
Object Oriented Programming techniques may be used in Modula-3, but their use is not required. Many of the other features provided in Modula-3 (modules, generics) can usually take the place of object orientation.Object support is intentionally kept to its simplest terms.
An object type (Termed a "class" in other object oriented languages) is introduced with the
OBJECT
declaration,which has essentially the same syntax as a
RECORD
declaration,although an object type is a reference type, whereas RECORDs in Modula-3 are not (similar to structs in C).
Exported types are usually named T by convention, and create a separate "Public" type to expose the methods and data.
For instance:
This defines an interface
Person
with two types, T
, and Public
, which is defined as an object with two methods, getAge
and init
. T
is defined as a subtype of Public
by the use of the <:
operator.To create a new
Person.T
object, we use the built in procedure NEW
with the method init
asModula-3's
REVEAL
construct provides a conceptually simple and clean yet very powerful mechanism for hiding implementation details from clients, with arbitrarily many levels of "friendliness".We use
REVEAL
to show the full implementation of the Person
interface from above.Note the use of the
BRANDED
keyword, which "brands" objects to make them unique as to avoid structural equivalence. BRANDED
can also take a string as an argument, but when omitted, a unique string is generated for you.Modula-3 is one of the few programming languages that requires that external references from a
module be strictly qualified. That is, a reference in module
A
to the object x
exported from module B
must take the form B.x
. It is notpossible in Modula-3 to import "all exported names" from a module.
Because of the language's requirements on name qualification and method overriding, it is impossible to break a working program simply by adding new declarations to an interface (any interface). This makes it possible for large programs to be edited concurrently by many programmers without any worries about naming conflicts; and it also makes it possible to edit core language libraries with the firm knowledge that no existing programs will be "broken" in the process.
Exceptions
ExceptionException
Exception may refer to:* An action that is not part of ordinary operations or standards* Exception handling, in programming languages** or a programming interrupt itself of which exception handling is meant to deal with....
handling is based on a
TRY
...EXCEPT
block system, which has since become common. One feature that has not been adopted in other languages, with the notable exceptions of Delphi, PythonPython (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
http://www.python.org/doc/faq/general/#why-was-python-created-in-the-first-place, Scalahttp://scala.epfl.ch and Visual Basic.NET, is that the
EXCEPT
construct defined a pseudo-CASE with each possible exception as a case in one EXCEPT clause. Modula-3 also supports a LOOP
...EXIT
...END
construct that loops until an EXIT
occurs, a structure equivalent to a simple loop inside a TRY
...EXCEPT
clause.Multi-Threaded
The language supports the use of multi-threading, and the synchronization between threads.The
MUTEX
is a built-in data structure, and the LOCK
statement locks the MUTEX
. The Modula-3 runtime may make use of a separate thread for garbage collection.
There is a standard module within the runtime library (libm3) named Thread,
which supports the use of multi-threaded applications.
Summary
In summary, the language features:- ModulesModularity (programming)Modular programming is a software design technique that increases the extent to which software is composed of separate, interchangeable components called modules by breaking down program functions into modules, each of which accomplishes one function and contains everything necessary to accomplish...
and interfacesInterface (computer science)In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software... - Explicit marking of unsafe code
- GenericsGeneric programmingIn a broad definition, generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters...
- Automatic garbage collectionGarbage collection (computer science)In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...
- Strong typingStrongly-typed programming languageIn computer science and computer programming, a type system is said to feature strong typing when it specifies one or more restrictions on how operations involving values of different data types can be intermixed...
, structural equivalence of types - ObjectsObject (computer science)In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...
- ExceptionsException handlingException handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....
- ThreadsThread (computer science)In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
Modula-3 is one of the rare languages whose evolution of features is documented.
In Systems Programming with Modula-3, four essential points of the language design are intensively discussed. These topics are: structural vs. name equivalence, subtyping rules, generic modules, and parameter modes like
READONLY
.Standard library features
Continuing a trend started with the CC (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
programming language, many of the features required to write real programs were left out of the language definition itself and instead provided via a number of standard libraries. Most of the interfaces below are described in detail in
Standard libraries providing the following features. This are called standard interfaces and are required (must be provided) in the language.
- Text: Operations on immutable string references, called
TEXT
s - Thread: Operations relating to threading, including
MUTEX
, condition variable, and thread pausing. The threading library provides pre-emptive threads switching - Word: Bitwise operations on unsigned integers (or machine words). Normally implemented directly by the compiler
- Floating-point interfaces
Some recommended interfaces implemented in the available implementations but are not required
- Lex: For parsing number and other data
- Fmt: Formatting various datatypes for printing
- Pkl (or Pickle): Object serialization of any reference types reachable by the garbage collector
- Table: Generic modules for mapsMAPSMaps is the plural of map, a visual representation of an area.As an acronym, MAPS may refer to:* Mail Abuse Prevention System, an organisation that provides anti-spam support...
As in C, I/O is also provided via libraries, in Modula-3 called
Rd
and Wr
. The object-oriented design of the Rd and Wr (readers and writers respectively) libraries is covered in detail in the book by Greg Nelson. An interesting aspect of Modula-3 is that it is one of few programming languages whose standard libraries have been formally verified not to contain various types of bugs, including locking bugs. This was done under the auspices of the Larch/Modula-3 (see Larch familyLarch family
The Larch family of formal specification languages are intended for the precise specification of computing systems. They allow the clean specification of computer programs and the formulation of proofs about program behavior....
) and Extended Static Checking
Extended static checking
Extended Static Checking is a collective name for a range of techniques for statically checking the correctness of various program constraints. ESC can be thought of as an extended form of type checking. As with type checking, ESC is performed automatically at compile time...
projects at DEC Systems Research Center.
Implementations
Several compilers are available, most of them open sourceOpen source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...
.
- DEC-SRC M3, the original.
- Olivetti Research Center (ORC) Modula-3 toolkit, originally a compiler, now available as a library for syntactic, lexical and semantic analysis of Modula-3 programs.
- Critical Mass CM3, a different successor of DEC-SRC M3
- Polytechnique Montreal Modula-3 PM3, a successor of DEC-SRC M3, currently merging with CM3
- EzM3, an independent lightweight and easily portable implementation, developed in connection with CVSupCVSupCVSup is a computer program written for Unix/Linux based systems that synchronizes files and directories from one location to another while minimizing data transfer using file-type specific delta encoding when appropriate...
- HM3, a successor of the pm3-1.1.15 release of PM3, with support of native threading using NPTL
- CM3, the successor to Critical Mass CM3. This is the only up to date, maintained and developed implementation. Releases are available from http://www.opencm3.net/releng/.
Since the only aspect of C data structures that is missing from Modula-3 is the
union type, all existing Modula-3 implementations are able to provide good binary compatibility with C language type declarations of arrays and structs.
Books
None of these books are still in print, although used copies are obtainable and some are digitized or partially digitized and some chapters of one them have previous or posterior versions obtainable as research reports from web.- Greg Nelson, ed. Systems Programming with Modula-3 The definitive reference on the Modula-3 language with interesting articles on object-oriented systems software construction and a documentation of the discussion leading to the final features of the language. There are some previously (see for Chapter two, for chapter four, for chapter five, for chapter six) and some posteriorly (see for Chapter one and more updated two, thus of both previous versions of language definition and, for chapter three and for chapter seven) of publishing versions of the majority of its eight chapters individually available from prior DECDigital Equipment CorporationDigital Equipment Corporation was a major American company in the computer industry and a leading vendor of computer systems, software and peripherals from the 1960s to the 1990s...
Systems Research CenterDEC Systems Research CenterThe Systems Research Center was a research laboratory created by Digital Equipment Corporation in 1984, in Palo Alto, California....
(SRC) as research reports for download. - Samuel P. Harbison, Modula-3 Easy to use class textbook.
- Robert SedgewickRobert Sedgewick (computer scientist)Robert Sedgewick is a computer science professor at Princeton University and a member of the board of directors of Adobe Systems....
, Algorithms in Modula-3 - Laszlo Boszormenyi & Carsten Weich, Programming in Modula-3: An Introduction in Programming with Style
- Renzo Orsini, Agostino Cortesi Programmare in Modula-3 : introduzione alla programmazione imperativa e a oggetti an Italian book of the language explaining its main features.
Projects using Modula-3
- The SPIN operating systemSPIN (operating system)The SPIN Operating System is a research project implemented in the computer programming language Modula-3, and is an Open Source project. It is designed with three goals in mind: flexibility, safety and performance. SPIN was developed at the University of Washington.The kernel can be extended by...
was implemented using Modula-3 as its programming language. - The CVSupCVSupCVSup is a computer program written for Unix/Linux based systems that synchronizes files and directories from one location to another while minimizing data transfer using file-type specific delta encoding when appropriate...
repository synchronization program was implemented in Modula-3. - The Obliq programming language which uses Modula-3 network objects ability to migrate objects over local networks transparently, allowing a distributed capability to Modula-3 object oriented programming paradigm. It has been used for building distributed applications, computer animations and web programming applications in the form of scripting extension to Modula-3.
External links
- Modula-3 Resource Page
- CM3 Implementation Website
- Modula-3 Home Page (now long dead, mirror)
- Modula-3: Language definition
- elego Software Solutions
- [news:comp.lang.modula3 Modula-3 newsgroup] (Mostly deserted)
- Modula-3 Development Mailing List (active)
- Notes from Caltech's CS2 class, taught in Modula-3 in 2002 and 2003.
- Caltech's CS3 class 2009.
- mirror Programming in Modula-3: program examples
- Building Distributed OO Applications: Modula-3 Objects at Work. Michel R. Dagenais. Draft Version (January 1997)
- [ftp://ftp.u-aizu.ac.jp/pub/lang/Modula/m3/faq/document/LangToolsLibs/root.ps Modula-3: Language, Libraries and Tools. Presentation on Modula-3 over 120 slides. Michael R. Dagenais]
- Object-Oriented Data Abstraction in Modula-3. Joseph Bergin (1997)
- Computerworld Interview with Luca Cardelli on Modula-3