Friday, October 5, 2012

Modula-2: A Pascal's Revision


1 History

        In the mid 1970's, after the language Pascal was designed, Niklaus Wirth was experimenting with concurrency which led to the design of Modula. Modula was never released and its development was discontinued after its publication. Wirth then built a language that was meant to be the single language for the new computer system called Lilith. Even though the computer was never a success, his new language Modula-2 was released in 1980.

Principal Concepts
  • The module as a compilation unit for separate compilation.
  • The co-routine as the basic building block for concurrent processes.
  • Types and procedures that allow access to machine-specific data.
Significant Language Features

        Modula-2 was designed based on Pascal and Modula but its improvements over Pascal included modules, low level features, co-routines, and syntactic features.

Modulesa tool for expressing the relations between major parts of programs and provide support for abstract data types.

Low Level Featuressmall language which can be implemented on a wide variety of microcomputers. contains facilities for high level and low level programming.

Coroutinesused for embedded systems that require concurrency without the overhead of large operating systems or large languages.

Syntactic Featureshas a small vocabulary and consists of few sentence structures. contains simple and consistant rules of syntax which makes it easy to learn.

Areas of Application

Modula-2 is a simple but yet a powerful language that is suitable for a wide range of applications.

  • Systems Programming
  • Concurrent Programming
  • Embedded Systems
  • Software Engineering
  • Education



Use in Embedded Systems 

Cambridge Modula-2

Cambridge Modula-2 by Cambridge Microprocessor Systems is based on a subset of PIM4 with language extensions for embedded development. The compiler runs on MS-DOS and it generates code for M68K based embedded microcontrollers running the MINOS operating system.

Mod51

Mod51 by Mandeno Granville Electronics is based on ISO Modula-2 with language extensions for embedded development following IEC1131, an industry standard for programmable logic controllers (PLC) closely related to Modula-2. The Mod51 compiler generates standalone code for 80C51 based microcontrollers.

Modula-GM

Delco Electronics, then a subsidiary of GM Hughes Electronics, developed a version of Modula-2 for embedded control systems starting in 1985. Delco named it Modula-GM. It was the first high level language used to replace machine language code for embedded systems in Delco's engine control units (ECUs). This was significant because Delco was producing over 28,000 ECUs per day in 1988 for GM; this was then the world's largest producer of ECUs.

Modula-2 was selected as the basis for Delco's high level language because of its many strengths over other alternative language choices in 1986. After Delco Electronics was spun off from GM (with other component divisions) to form Delphi in 1997, global sourcing required that a non-proprietary high-level software language be used. ECU embedded software now developed at Delphi is compiled with commercial C compilers.

A “hello world” code


Frequently Asked Questions
What is Modula-2?
A. Modula-2 is a programming notation that corrects some of the deficiencies of Pascal. It is suitable for learning programming, for large projects written and maintained in the fashion of professional software engineers, and for real time embedded systems. Modula-2 is small, expressive, easy to learn, and to read.
Who developed Modula-2?
Modula-2 was developed by Niklaus Wirth at ETH in Zurich, Switzerland in the late 70's. Wirth also developed Algol-W, Pascal, Modula, and Oberon and the Lilith computer, a natively Modula-2 machine (see section 1.15).
Where is this language described?
In Programming in Modula-2 3rd edition published by Springer-Verlag in 1985. For the purposes of distinguishing this from later variants, this description will be referred to herein as classical Modula-2.
How do you pronounce Herr Wirth's name?
It is incorrect to call him by his value (worth.) Instead his name is veart.
How does Modula-2 fit into the language zoo?
It is a descendent of Pascal and Modula, and one predecessor of Modula-2+, Modula-2*, Modula-3, Modula-2 R10, Oberon, Oberon-2, and various object oriented versions of these. The latter languages are not replacements for Modula-2, merely later notations in the same family, having strengths and weaknesses of their own. Modula-2 is sometimes classified with Ada and C++ as the trio of modern languages in view of their expressive power. Modula-2 is smaller and more readable than either. Modula-2 strongly influenced later versions of Pascal and Python.
What are the differences between Modula-2 and Standard Pascal?
Modula-2 has separately compiled library modules, and makes much less use of blocks (begin...) than Standard Pascal. Identifiers are case sensitive; there is no goto label; and I/O is in libraries rather than built in. The IF statement is more versatile; and there are facilities for concurrent programming via coroutines. Extended Pascals may have some of these features.
What is ISO Standard Modula-2?
A committee of ISO JTC1/SC22/WG13 with delegates from several countries met from 1987 to work on a standard description of Modula-2 and a set of standard library modules.
The official home of the ISO Modula-2 working group WG13 is at http://sc22wg13.twi.tudelft.nl/

What difference is there between classical and ISO Modula-2?
ISO Modula-2 has resolved most of the ambiguities in classical Modula-2. It adds the data type COMPLEX and LONGCOMPLEX, exceptions, module termination (FINALLY clause) and a complete standard I/O library. There are numerous minor differences and clarifications.

Where and for what is Modula-2 used?
Modula-2 is widely used for teaching the fundamentals of sound programming techniques, data structures, and software engineering in many parts of the world. It has been the language of choice in much of Europe, though Java and C++ have made great inroads. Modula-2 has features that make it superior to other languages for large projects and for programming and real time controllers.


Just Some Anecdotes 

  
"Back in 92-93 I worked for the Australian National Uni's Research School of Earth Sciences writing Noble, a large suite of programs to control mass spectrometers and analyze all the data. Everything was written in Modula-2 (the only reason I took the job!). In fact, one of the reasons I decided to try making a living from shareware was so that I could keep using Modula-2."

-       Andrew Trevorrow (akt@kagi.com) who is the author of several Macintosh programs written in p1 Modula-2: OzTex (standard Tex implementation on the Mac) X-Words (a meta-Scrabble word game), Anagrams (a fast and friendly anagram generator), LifeLab (a software laboratory for 2D cellular automata, Googolator (an arbitrary-precision calculator, X-Words Deluxe (a meta-Scrabble-like game), and CrossCards (a combination of Scrabble and Poker.)


“Our BoardWizard range of test equipment has compilers,pseudo-code interpreters and a complete test operating system written in M2. The code was written for one tester in 1987 and has been maintained from that date to the present. New tester models have added and new interface and UI code has been written, indeed sections have been completely re-written but much of the core test logic is untouched since about 1990 when I shifted to management. Much of the code is unknown to those who maintain it - yet when i look at it after several years I can still explain it to others even though comments are sparse. I believe that that is the hallmark of a great programming language. (Emphasis added.)”

        -        a message sent in by a maker of test equipment

Though I've unfortunately moved on in my "day job" to Windows support :( :( :( with an occasional task in HTML shuffling (even worse!), I used to do scientific research laboratory programming, and my Photomultiplier Monitoring program, for long term data collection using very sensitive Hamamatsu PMTs, written with Stony Brook M2 starting about 8 years ago is still being used, and in fact has spread to a number of laboratories here and there.


        -        Tom Breedon

The following products were made using Modula-2. The programs are all about 100,000 lines long, and 99% Modula-2, with about 1% assembler code for performance in critical areas.

  • Flying Colors 2, Anime Designer DragonBall, Action Designer Ultraman, Tamagotchi Sketch, Curious George Paint and Print Set -- all paint and creativity programs.
  • Gorgeous Mail -- a new years card making program
  • JuniorNet web activities -- various creativity activities for JuniorNet web subscription service
  • Discus -- CD label making program
  • Web Workshop Deluxe -- Web site design product
                         -   answer sent in by a developer:
Magic Mouse Productions
12615 Sir Francis Drake Blvd.
Inverness, CA 94937 USA
1-415-669-7010

Just some additional information




General Motors and its subsidiary Delco have done their programming in General Motors Modula-2. Up to a point, all GM car computers were programmed in this language.

The Proceedings of the Joint Modular Languages Conference, JMLC 2003 (LNCS 2789), contains an article by Koltashev wherein he discusses the benefits of using Modula-2 for the onboard-software used in Russian telecommunications satellites.

Why is Modula-2 a good language for large commercial projects?

 It supports modular design which reduces errors and cuts down on maintenance time. This also allows platform dependencies to be isolated, increasing portability. I/O is found in several type-specific modules, so linkers only patch in the I/O code that's needed, making programs smaller and faster. This is in sharp contrast to, say, the versatile but resource hungry printf in C.

Is there any Modula-2 compiler for iPhone application development?

A: Not yet. However, Objective Modula-2 targeting the Objective-C runtime and associated frameworks (including Cocoa Touch) will be usable for iPhone development once the reference compiler is completed.

10 What can we say about MODULA-2?

"I find Modula-2 easy to learn and I think those who'd want to enter the world of programming should start with this programming language. 
                                                                   - Mulet, A Mabelle (2010-58569)

"Indeed a revision of Pascal. Want a PL that supports multiprogramming? Modula-2 : I've got it all for you! " 

                                                                   - Ondoy, Karen Hazel C. (2010-33142)

11 Sources
  • www.wikipedia.com
  • http://www2.latech.edu/~acm/helloworld/modual2.html (hello world example)
  • http://groups.engin.umd.umich.edu/CIS/course.des/cis400/modula2/modula2.html
  • Christian, Kaare (1986). A Guide To Modula-2. Springer-Verlag, New York.
  • McKay, Kenneth and Moore, John (1987). Modula-2 Text and Reference. Prentice-Hall, NJersey.
  • Sebesta, Robert (1996). Concepts of Programming Languages . Addison-Wesley Publishing, CA.
  • http://www.arjay.bc.ca/Modula-2/m2faq.html

Members
Ondoy,  Karen Hazel C. (2010-33142)
Mulet, A Mabelle (2010-58569)
Estayan, John Darrel P.
Diño, Joshua U.

CMSC 124 T-6L

No comments:

Post a Comment