By John Bogan
Abstract: MODULA Corporation of Provo, Utah has shipped a $90.00 Beta site version of Modula-2 which runs reasonably well on a single disk 128K Macintosh. This paper attempts to make the case that Modula-2 deserves a thorough analysis to determine if it is the ideal standalone development language for serious commercial software on the Apple Macintosh. The conclusion of this paper is that Modula-2 will soon become the language of choice for farsighted software developers through the rest of the 1980s and it is through the efforts of enlightened companies such as MODULA Corp. that this joyous result will come about.
A Short History of Modula-2
The history of Modula-2 is the history of its designer, Dr. Niklaus Wirth. We pick up the story in the late 1960s when Dr. Wirth was a member of a large committee whose task was to design a successor to the language ALGOL-60, a highly popular language in Europe. ALGOL-60 is widely regarded as the inspiration for the discipline of Structured Programming which is the most significant breakthrough in software engineering in the past two decades. The result of this committees efforts was ALGOL-68, a kludge. No coherent design philosophy guided this effort resulting in a chaotic collection of features reminiscent of PL/I. In short, failure.
At this point Dr. Wirth abandoned the committee approach and decided to design his own language. Influenced by the structured programming theories of Dijkstra, Hoare and Dahl, Dr. Wirth set out to construct a language he could use to teach his own students the fundamentals of good programming. He began with some modest goals.
[The development of the language Pascal is based on two principal aims. The first is to make available a language suitable to teach programming as a systematic discipline based on certain fundamental concepts clearly and naturally reflected by the language. The second is to develop implementations of this language which are both reliable and efficient on presently available computers.] Pascal Report, page 1, 1974, Niklaus Wirth
The rest is history. As anyone who follows the computer industry well knows Pascal is one of the major influences on the software world today, particularly in the microcomputer world. To cite only one example the second largest manufacturer of personal computers in 1984 appears to have adopted Pascal as its standard design language. That company is, of course, Apple Computer, Inc. As I understand it most of the algorithms, data structures and techniques designed into the LISA and the Mac began life as Pascal programs.
But Pascal has significant flaws. Volumes have been written disparaging Pascal as a systems programming language and as a vehicle for writing applications of all stripes and colors. (Never mind that the language was never intended to do any of these things.) Further, and more disturbing, Pascal has been repeatly bastardized by its implementors with a wide variety of (incompatible) extensions. After a decade in the field there is no such thing as Standard Pascal any more than there is a tooth fairy. Nevertheless, many talented software people believe that even with its flaws Pascal is still the best practical general purpose language we have at our disposal. I believe this situation is about to change.
On with Wirths story. After largely washing his hands of Pascal Dr. Wirth turned his attention to multitasking and the problems of building large commercial programs using teams of programmers. As it happens Pascal is utterly unsuited for both of these activities. So Wirth designed himself a new, very simple language he called Modula. This language was never particularly practical it was more like a hack from one of the more gifted computer scientists around. However, it laid the groundwork for the concepts of seperate compilation, modularity and libraries.
In 1976 Dr. Wirth took a sabbatical from his mountain hideaway, Eidgenössische Technische Hochschule, Instut für Informatik, better known as ETH in Zürich, Switzerland and visited that fount of inspiration - Xerox PARC. As Mac enthusiasts we all know what that means. Personal workstations, high resolution bit maps, mice, windows, icons, Smalltalk etc. Less well known is the Xerox systems implementation language MESA. This language is a derivative of Pascal suitable for team implementation of low-level systems programs. The pieces were falling into place. Like many visitors to PARC Dr. Wirth came away with an inspiration.
Dr. Wirth was tired of the bitching and moaning surrounding Pascal.
[If a language proves to be only marginally suitable for some application that was obviously not envisaged by its originator, we should muster the courage to build a new, truly adequate tool, instead of just grafting a fix onto the existing one.] Byte, April 1983, pg. 386, Niklaus Wirth
Dr. Wirths inspiration was to build a new computer system from the ground up. A machine which would be programmed in one language from soup to nuts. From OS to text editor to graphics editor to who-knows-what, databases, spreadsheets, adventure games, what- ever. Recognizing that a one language machine would require the use of dangerous low-level facilities as well as the safety, convenience and productivity of the high level structured features he sifted through his encyclopedic knowledge of Pascal, Modula and MESA and in 1978 he defined his new language. To quote:
[Modula , a small language ...featured a facility to partition programs into modules with explicitly specified interfaces. This was precisely the facility needed to allow the introduction of so-called low-level facilities in the high-level language, because it allowed you to encapsulate them and to constrain their danger- ousness to clearly delineated parts of a program. Hence, the choice for the new language was Pascal, augmented by the module and a few other facilites, and regularized by a more systematic syntax. Thus was born Modula-2.] Byte, August 1984, pg. 146, Niklaus Wirth
Dr. Wirth had his ideal language. He then sat down with a couple of hardware types and some graduate students and built a bit-slice (AM2901) single-user high resolution graphic workstation with windows, mouse and multiple font editor with laser printer long before the Macintosh ever saw the light of day! He called his machine Lilith. The sole American distributor for the Lilith and the Modula-2 compiler which this machine is built around is MODULA Corporation of Provo, Ut., makers of Modula for Mac.
The following program is an imple- mentation of the Sieve of Eratosthenes expressed in Modula Corporations version of Modula-2 for the Apple Macintosh 128K. The following results were obtained when this program was compiled and executed.
The source (Prime.MOD) = 1,617 bytes.
Compile time was -1:45
The M-code (Prime.REL) = 324 bytes.
Link time was -1:20
The execution module = 4,348 bytes.
Execution time was -1:11 or 71 seconds.
Modula-2 Compiler,Interpreter Ver. 1.0.
MODULE Prime; (* Sieve of Eratos. *)
(* $R- disable subrange and type conv *)
(* $T- disable index checking *)
FROM InOut IMPORT WriteLn, WriteCard, WriteString;
FROM Terminal IMPORT ClearScreen;
CONST Size = 8190;
VAR i, prime, k, count, iter : CARDINAL;
Flags : ARRAY[0..Size] OF BOOLEAN;
WriteLn; WriteString(10 Iterations);
FOR iter := 1 TO 10 DO
count := 0;
FOR i := 0 TO Size DO Flags[i] :=
FOR i := 0 TO Size DO
IF Flags[i] THEN
prime := i + i + 3;
k := i + prime;
WHILE k <= Size DO
Flags[k] := FALSE;
WriteLn; WriteCard(count,6); WriteString( Primes)
A Comparison between versions and machines
Code System Seconds
1. Lilith 4.24
2. Hamburg Vax 11/750 4.64
3. Logitech Eagle 6.90
4. ETH LSI-11 8.78
5. Logitech IBM PC 15.80
6. Volition Sage 66.14
7. Modula Macintosh 71.00
8. MRI Eagle 90.70
9. MRI IBM PC 203.60
10. Volition IBM PC 209.50
11. Volition Apple II 377.00
Source: Seven Modula-2 Compilers Reviewed by Terry L. Anderson Journal of Pascal, Ada & Modula-2 Vol.3 No.2