Modula2 - PowerPoint PPT Presentation

About This Presentation
Title:

Modula2

Description:

Design and Development ... Supports Modular design. Reduces errors ... Large projects written and maintained in the fashion of professional software engineers ... – PowerPoint PPT presentation

Number of Views:113
Avg rating:3.0/5.0
Slides: 16
Provided by: Dima154
Category:
Tags: modula2

less

Transcript and Presenter's Notes

Title: Modula2


1
Modula-2
  • From design and development to uses and
    performance
  • Dmitry Nesvizhsky
  • CIS24
  • Professor Danny Kopec

2
Design and Development
  • Modula-2 was developed by
    Niklaus Wirth at ETH in Zurich,
    Switzerland in the late 70's
  • Wirth focused on building a single language for a
    new computer system that was later called Lilith

3
Design and Development
  • Modula-2
  • Procedural Programming Language
  • Block-structured
  • Design was based on Pascal and Modula
  • Improvements over Pascal
  • Modules
  • Low-level features
  • Coroutines
  • Syntactic features

4
Design and Development
  • Modules
  • A tool for expressing the relations between major
    parts of programs and provide support for
    abstract data types
  • Low-Level Features
  • a small language, which can be implemented on a
    wide variety of microcomputers
  • Contains facilities for high-level and low-level
    programming

5
Design and Development
  • Coroutines
  • Used for embedded systems that require
    concurrency without the overhead of large
    operating systems or large languages
  • Syntactic Features
  • Have a small vocabulary and consists of few
    sentence structures
  • Contains simple and consistent rules of syntax,
    which makes it easy to learn

6
Superiority of Modula-2
  • Supports Modular design
  • Reduces errors and cuts down on maintenance time
  • Allows platform dependencies to be isolated
  • Increases portability
  • I/O code is smaller and faster than the
    resource-hungry printf in C

7
Superiority of Modula-2
  • Modula-2 is a higher-level language than C
  • E.g. with respect to pointers
  • Pointers have types that depend on what is
    pointed to
  • Modula-2 treats these as addresses only by
    flagging this fact in the code
  • Identifiers are case sensitive
  • No GOTO label

8
Uses of Modula-2
  • Suitable for learning programming
  • Large projects written and maintained in the
    fashion of professional software engineers
  • real-time embedded systems
  • Safety-critical areas
  • Traffic control systems
  • It is small, expressive, easy to learn, and to
    read

9
Code Example 1
  • The program prints Hello World! to the screen
  • MODULE PrintHelloWorld
  • (This program prints "Hello world!" on the
    standard output device)
  • FROM InOut IMPORT WriteString, WriteLn
  • BEGIN
  • WriteString('Hello world!')
  • WriteLn
  • END PrintHelloWorld.

10
Code Example 2
  • Given the names of the input and output files,
    the following program reads the numbers from the
    input file and outputs the sum and average into
    the output file

11
Code Example 2 (continued)
  • MODULE SumAndAverage
  • FROM InOut IMPORT ReadInt, WriteString, WriteLn,
    WriteInt, OpenInput, OpenOutput, CloseInput,
    CloseOutput, Done
  • VAR 
  • NINTEGER
  • XINTEGER
  • SUMINTEGER
  • AVERAGEINTEGER

12
Code Example 2 (continued)
  • BEGIN
  • WriteString('Enter the names of the output,
    input files')
  • WriteLn
  • OpenOutput("OUT")
  • IF NOT Done THEN
  • WriteString('Output file cannot be opened')
  • WriteLn
  • HALT
  • END
  • OpenInput("IN")
  • IF NOT Done THEN
  • CloseOutput
  • WriteString('Input file cannot be opened')
  • WriteLn
  • HALT
  • END

13
Code Example 2 (continued)
  • N0
  • SUM0
  • ReadInt(X)
  • WHILE Done DO
  • WriteInt(X,3)
  • WriteLn
  • NN1
  • SUMSUMX
  • ReadInt(X)
  • END

14
Code Example 2 (continued)
  • WriteString('The Sum is ')
  • WriteInt(SUM,1)
  • WriteLn
  • AVERAGESUM DIV N
  • WriteString('The Average is')
  • WriteInt(AVERAGE,1)
  • WriteLn
  • CloseOutput
  • CloseInput
  • END SumAndAverage.

15
Modula-2 Performance Table
Write a Comment
User Comments (0)
About PowerShow.com