Title: Lecture 2 History of Programming Languages
1Lecture 2 History of Programming Languages
UNIVERSITY OF CENTRAL FLORIDA
2Class 2 History of Programming Languages
- FORTRAN
- ALGOL ? SIMULA
- COBOL
- PL/1
- BASIC
- PASCAL
- C
- LISP
- The so called High Level Programming Languages
started their development in the mid 50s.
3FORTRAN (FORmulaTRANslation)
- Fortran was designed to develop scientific
applications on the IBM 704(with punched card
inputs) computer and the major role in its design
was run-time efficiency. - Developed by John Backus and his group in 1954.
4PUNCH CARD
                                                                                                                                                                                                                                                                                                                   Â
5Main features
- Comments
- Assignment statements that allowed mathematical
expressions of some complexity on the
right-hand side - The simplicity of writing loops with the DO
statement - Subroutines and functions Not a new idea but it
was implemented employing a symbolic notation - Formats for input and output Difficult feature
to implement on early computers - Machine independence A fortran program could run
on different machines
6Main reasons for its popularity
- It made efficient use of programming time
- Easy to learn (good for non-specialist
programmers) - It was supported by IBM
- It simplifies INPUT/OUTPUT
7Example of a Fortran Program
- C FORTRAN PROGRAM TO FIND MEAN OF N NUMBERS
- C AND NUMBER OF VALUES GREATER THAN MEAN
- DIMENSION A(99)
- REAL MEAN
- READ (1,5)N
- 5 FORMAT (I2)
- READ (1,10) (A(I), I1, N)
- 10 FORMAT (6F10.5)
- SUM 0.0
- DO 15 I1, N
- 15 SUM SUM A(I)
- MEAN SUM/FLOAT(N)
- NUMBER 0
- DO 20 I1, N
- IF (A(I).LE.MEAN) GOTO 20
- NUMBER NUMBER 1
- 20 CONTINUE
- WRITE (2,25) MEAN, NUMBER
- 25 FORMAT (8H MEAN , F10.5, 5X, 20H NUMBER OVER
MEAN , I5)
8Development
- The first design of Fortran was made in 1954
(Fortran 0) - The first implementation was developed in
1957(Fortran I) - A better compiler was developed in 1958 (Fortran
II) - After many revisions in 1962 a stable compiler
(Fortran IV) - First NASI standard 1966 (Fortran 66)
- After a major revision new features are added
(Fortran 77) - A more modern Fortran is created in 1990 (Fortran
90)
9FORTRAN 77
FORTRAN 90
- Offers features that are common to modern
programming languages - Records
- Modules
- Pointers
- Subprograms can be recursive
10FORTRAN 95
- FOR ALL construct to aid vectorization
FORTRAN 2003
- Object-oriented programming
- IEEE floating-point arithmetic
11 FORTRAN 0 FORTRAN I(1957)
COBOL(1960) ALGOL 58 FORTRAN
II ALGOL 60 FORTRAN IV PL/1(1964)
BASIC FORTRAN 66
FORTRAN 77 FORTRAN 90
12Referencing in FORTRAN
- All variables are local to each routine
- The local environment of a subroutine consists
of the variables, arrays, etc. declared at the
start of the subprogram. - The local environment is retained between calls
because the activation record is allocated
statically. - Global variables are created using the COMMON
declaration - COMMON /ltnamegt/ltvar or arraygt, ltvar or arraygt,
ltvar or arraygt,
13Example COMMON/ Globalvar/X/Y/A(20)
- program main
- real X, Y
- common /BLK/ X, Y
- statements
- stop
- End
-
- subroutine sub1 ( arguments)
- declarations of arguments
- real X, Y
- common /BLK/ X, Y
- statements
- return
- End
-
- subroutine sub2 ( arguments)
- declarations of arguments
- real X, Y
- common /BLK/ X, Y
14FORTRAN Memory layout
System data and I/O buffers
Code and local data for main program
BLK (common block)
Code and local data for sub1
Code and local data for sub2
System I/O routine
15Implementing FORTRAN 77 SubprogramsActivation
Record
16FORTRAN 77 Subprograms
- FORTRAN 77 subprograms cannot be recursive.
- Variables declared in subprograms are statically
allocated. Therefore, both parts of a FORTRAN 77
Subprogram (the code and the local variables)
have fixed sizes. - So the activation record of a FORTRAN 77
subprogram has a fixed size, and therefore can be
statically allocated.
17FORTRAN 77 Activation Record Format
18FORTRAN 77 Code and Activation Records for
Subprograms A, B, and C
COMMON is a mechanism used by FORTRAN 77 for
referencing nonlocal variables
COMMON Storage
Local variables
MAIN
A
Data
B
C
MAIN
A
Code
B
C
19ALGOL (ALGOrithmic Language)
- ALGOL was develop in 1958 as a committee
effort to design a language for the description
of computing processes in publications. - The objectives of the language were stated as
follows - It should be close as possible to standard
mathematical notation and be readable without to
much additional explanation. - It should be mechanically translate into machine
code.
20ALGOL 58 ALGOL 60 ALGOL
68 ALGOL W
SIMULA 67
PASCAL
21Major Concepts introduced in ALGOL(1)
- Language definition a formal definition in
Backus Naur Form (BNF) was used to define the
syntax for the first time this led to
syntax-directed compilers. - ALGOL 60 was structured It was the originally
block structured language and variables were not
visible outside the block in which they were
declared. - Arrays could have variables bounds.
- Contained several structured control statements
22Major Concepts introduced in ALGOL(2)
- Sequence S1,S2,,Sn
- Selection (IF-THEN-ELSE)
- Iteration (For I 1 step 1 until n do)
- First language to introduce recursive procedures.
23Why ALGOL 60 did not supersede FORTRAN?
- Compilers came out approximately three years
after Fortran. - As it had more features than Fortran it was
harder to learn. - IBM customers were happy with Fortran.
- Fortran compilers were simpler to produce and
more efficient. - Algol 60 had not official Input/output therefore
they left this feature to the individual
manufacturers.
24Example of an Algol program
- begin
- comment this program finds the mean of n numbers
and the number of values greater than the mean - integer n
- read(n)
- begin
- real array a1n
- integer i, number
- real sum, mean
- for i 1 step 1 until n do
- read(ai)
- sum 0.0
- for i 1 step 1 until n do
- sum sum ai
- mean sum/n
- number 0
- for i 1 step 1 until n do
- if ai gt mean then
- number number 1
- write (MEAN , mean, NUMBER OVER MEAN
, number)
25 ALGOL 60 ALGOL W(1966) ALGOL68 SIMULA
67 BCPL PASCAL C
MODULA C ADA(83)
OBERON Eiffel(90)
ADA(95) JAVA
26- The successor of ALGOL 60 was ALGOL W which was
proposed by Wirth and Hoare in 1966 . - The more important changes and additions were(1)
- Records and references allowed linked list,
trees and graphs. - The case statement.
- Changes which separate for and While.
- Procedures and function parameters could be
passed by values - and by name.
- Long real and complex data type were introduced
(complex - arithmetic)
27The successor of ALGOL 60 was ALGOL W which was
proposed by Wirth and Hoare in 1966 . The more
important changes and additions were(2)
- The bits data type gave low-level processing
ability. - Some string facilities were included.
- Assert statement were allowed and the assertion
tested during a program run. - Concurrent execution was implemented (B6700)
28- The next step was ALGOL 68 which amid its
interesting features introduced - An economy of constructs produce a core
- language with a small number of powerful
- constructs.
- Orthogonality This was its major design goal.
- There ware no interactions between constructs
- when they were combined. Having determined
- how a feature worked in one situation, it
could be - expected to behave in a similar way in any
other - situation.
29Run-time stack
- The run-time stack and the activation record
allows us to have more than one instance
(incomplete execution) of a subprogram at a given
time. - Recursion adds the possibility of multiple
simultaneous activations (incomplete execution)
of a subprogram at a given time.
30Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real  procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1
/ end( P2 ) Â begin P2 / calls
P2 / end ( P1 ) Â begin P1(R1, T1,
A1) / calls P1 / end( program )
31Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real  procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls
P1 / end( program )
Activation record for P0
32Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real  procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls
P1 / end( program )
Activation record for P0
33Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real  procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1
/ end( P2 ) Â begin P2 / calls
P2 / end ( P1 ) Â begin P1(R1, T1, A1)
/ calls P1 / end( program )
Activation record for P0
34Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1
/ end( P2 ) Â begin P2 / calls
P2 / end ( P1 ) Â begin P1(R1, T1, A1)
/ calls P1 / end( program )
Activation record for P0
35Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1
/ end( P2 ) Â begin P2 / calls
P2 / end ( P1 ) Â begin P1(R1, T1, A1)
/ calls P1 / end( program )
Activation record for P1
Activation record for P0
36Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1
/ end( P2 ) Â begin P2 / calls
P2 / end ( P1 ) Â begin P1(R1, T1, A1)
/ calls P1 / end( program )
Activation record for P1
Activation record for P0
37Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls
P1 / end( program )
Activation record for P1
Activation record for P0
38Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls P1
/ end( program )
Activation record for P1
Activation record for P0
39Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls P1
/ end( program )
Activation record for P1
Activation record for P0
40Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls P1
/ end( program )
Activation record for P2
Activation record for P1
Activation record for P0
41Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls
P1 / end( program )
Working space for Procedure P2
Activation record for P2
Memory for the variable T2
Memory for the variable R2
Activation record for P1
Activation record for P0
42Program
Stack
program P0 var R1, T1 real A1
array05,020 of real  procedure P1( X
real var T real Y array05,020 of
real) Â procedure P2 var R2, T2
real A2 array05,020 of
real begin R2 5 T2
25 P1(R2, T2, A2) / calls P1 / end(
P2 ) Â begin P2 / calls P2 / end
( P1 ) Â begin P1(R1, T1, A1) / calls P1
/ end( program )
Working space for Procedure P2
Activation record for P2
Pointer to the elements of A2
Memory for the variable T2
Memory for the variable R2
Activation record for P1
Activation record for P0
43 Stack state while P2 is executing
Working space for Procedure P2
Activation record for P2
Elements of array A2
Pointer to the elements of A2
Memory for the variable T2
Memory for the variable R2
Activation record for P1
P2 code
Activation record for P0
P1 code
Elements of array A1
44 FORTRAN 0 Flow-Matic (Grace Hopper-57) FOR
TRAN I(1957) COBOL(1960) ALGOL
58 FORTRAN II ALGOL 60 FORTRAN
IV PL/1(1964) BASIC FORTRAN
66 FORTRAN 77 FORTRAN 90
45COBOL (Common Business Oriented Language)
- COBOL was based on the Flow-Matic
language(1957), developed by Grace Hopper, and
IBM's specification of its planned Commercial
Translator. - COBOL is essentially a data processing language
and that is the reason why it differs
significantly from FORTRAN and ALGOL. -
- Several design principles guided the design of
COBOL - separate data procedures
- machine dependent statements in one place
- Naturalness (English-like form)
- ease of transcription to require media (cards at
the time) - effectiveness of problem structure
- ease of implementation (for compiler writers)
- physically available character set (printable)
- long data names
46COBOL-60 (First Compiler Only Three
DIVISIONS) COBOL-68 (standardized version -
(ANSI ) American National Standards
Institute) COBOL-74 (revisions to improve
COBOL-68 and interaction with remote devices )
COBOL-85 (facilities for structured
programming - DB2 and SQL support) COBOL 2002
(Object Oriented Programming)
47Main features
- The language is simple
- No pointers
- No user defined types
- Record data type
- Self documented
48A COBOL program is divided in four parts or
divisions
- Division Name Contains
- IDENTIFICATION Program identification.
- ENVIRONMENT Type of computer used.
- DATA Buffers, constants, work areas.
- PROCEDURE The processing (program logic).
49A COBOL program is divided in four parts
- The identification division Contains commentary
and program documentation. - 000100 INDENTIFICATION DIVISION.000110
PROGRAM-ID. EXAMPLE-1-PROG.000120 AUTHOR. TIM R
P BROWN.000130 INSTALLATION. XYZ GROUP.000140
DATE-WRITTEN. 5/15/06.000150 DATE-COMPILED.00016
0 SECURITY. LOCAL GROUP
50- The environment division Contain
machine-dependent program specifications. Thus,
it specifies the connections between the COBOL
program and the external data file. - 000260 ENVIRONMENT DIVISION.
- 000270 CONFIGURATION SECTION.
- 000280 SOURCE-COMPUTER. IBM PC.
- 000290 OBJECT-COMPUTER. IBM PC.
- 000300 INPUT-OUTPUT SECTION.
- 000310 FILE-CONTROL.
- 000320 SELECT INPUT-FILE ASSIGN TO 'input.dat
- 000330 ORGANIZATION IS LINE SEQUENTIAL.
- 000340 SELECT PRINT-FILE ASSIGN TO PRINTER.
51- The data division Gives a logical description
of the data. - 000800 DATA DIVISION.
- 000900 FILE SECTION.
- 001000 FD SALESPERSON-FILE.
- 001100 01 SALESPERSON-RECORD.
- 001200 05 FILLER PIC XX.
- 001300 05 SP-NUMBER PIC X(4).
- 001400 05 SP-NAME PIC X(18).
- 001500 05 FILLER PIC X(21).
- 001600 05 SP-CURRENT-SALES PIC
9(5)V99. - 001700 05 SP-CURRENT-RETURNS PIC 9(4)V99.
- 001800 FD REPORT-FILE.
- 001900 01 REPORT-RECORD.
- 002000 05 FILLER PIC X(10).
- 002100 05 RT-NUMBER PIC X(4).
- 002200 05 FILLER PIC X(6).
- 002300 05 RT-NAME PIC X(18).
- 002400 05 FILLER PIC X(6).
- 002500 05 RT-CURRENT-SALES PIC ZZ,ZZZ.99.
52- The procedure division Contains the algorithms
necessary to solve the problem. - 000900 PROCEDURE DIVISION.000910
CONTROL-PARAGRAPH.000920 PERFORM
READ-DATA-FILE000930 PERFORM CALULATE-PRICES0009
40 PERFORM PRINT-PRICE-REPORT000950 STOP RUN.
53Example of a COBOL program(Hello world)
- 000010 IDENTIFICATION DIVISION.
- 000020 PROGRAM-ID. HELLO-WORLD-PROG.
- 000030 AUTHOR. TIMOTHY R P BROWN.
- 000040The standard Hello world program
- 000050
- 000060 ENVIRONMENT DIVISION.
- 000070
- 000080 DATA DIVISION.
- 000090 WORKING-STORAGE SECTION.
- 000100 01 TEXT-OUT PIC X(12) VALUE 'Hello
World!'. - 000110
- 000120 PROCEDURE DIVISION.
- 000130 MAIN-PARAGRAPH.
- 000140 DISPLAY TEXT-OUT
- 000150 STOP RUN.
54Example program 2
- 000100 ID DIVISION.
- 000200 PROGRAM-ID. ACCEPT1.
- 000300 DATA DIVISION.
- 000400 WORKING-STORAGE SECTION.
- 000500 01 WS-FIRST-NUMBER PIC 9(3).
- 000600 01 WS-SECOND-NUMBER PIC 9(3).
- 000700 01 WS-TOTAL PIC ZZZ9.
- 000800
- 000900 PROCEDURE DIVISION.
- 001000 0000-MAINLINE.
- 001100 DISPLAY 'ENTER A NUMBER '.
- 001200 ACCEPT WS-FIRST-NUMBER.
- 001300
- 001400 DISPLAY 'ANOTHER NUMBER '.
- 001500 ACCEPT WS-SECOND-NUMBER.
- 001600
- 001700 COMPUTE WS-TOTAL WS-FIRST-NUMBER
WS-SECOND-NUMBER. - 001800 DISPLAY 'THE TOTAL IS ',
WS-TOTAL.
55 Some basic commands to be used in the
Procedure Division
- MOVE zero to I, J, K
- ADD a TO b.
- ADD c TO a GIVING c.
- COMPUTE x a b c.
- SORT input-file
- ON ASCENDING KEY k
- USING inventory-file
- GIVING sorted-inventory-file
- DISPLAY totalcost.
- ACCEPT identifier.
56000020 IDENTIFICATION DIVISION. 000040
PROGRAM-ID. MEAN. 000060 AUTHOR. JOHN
DOE. 000080 Program to find the mean and number
of values greater than the mean 000100 000120
DATA DIVISION. 000140 000160 WORKING-STORAGE
SECTION. 000180 01 N PIC 999 VALUE
ZEROS. 000200 01 I PIC 999 VALUE
ZEROS. 000220 01 NUMBER PIC 999 VALUE
ZEROS. 000240 01 MEAN PIC 999V999 VALUE
ZEROS. 000260 01 SUM PIC 999V999 VALUE
ZEROS. 000280 01 A PIC 999V999 OCCURS 100
TIMES VALUE ZEROS. 000300 000320 000340 PROCEDURE
DIVISION. 000360 000380 DISPLAY "ENTER NUMBER
OF ARRAY ELEMENTS ". 000400 ACCEPT
N. 000420 000440 ENTER-NUMBER. 000460 ADD 1 TO
I. 000480 DISPLAY "ENTER NUMBER ". 000500
ACCEPT A(I). 000520 IF I lt N GO
ENTER-NUMBER. 000540 MOVE 0 TO I. 000560 GO
SUM-NUMBER. 000580 000600 SUM-NUMBERS. 000620
ADD 1 TO I. 000640 COMPUTE SUM SUM
A(I). 000680 IF I lt N GO SUM-NUMBERS. 000700
COMPUTE MEAN SUM / N. 000720 MOVE 0 TO
I. 000740 GO GREATER-NUMBER. 000760 000780
GREATER-NUMBER. 000800 ADD 1 TO I. 000820
IF A(I) gt MEAN ADD 1 TO NUMBER. 000840 IF I lt
N GO GREATER-NUMBER. 000860 GO OEJ. 000880
000900 EOJ. 000920 DISPLAY "MEAN ",
MEAN. 000940 DISPLAY "NUMBER OVER MEAN ",
NUMBER. 000960 STOP RUN. 000980 001000
57COBOL continues to progress with work being
done in the Object-Oriented COBOL standard.
58PROGRAMMING LANGUAGE 1 (PL/1)
- In the early 1960s two categories of
programmers could be distinguished - Scientific programmers (Fortran)
- Commercial programmers (COBOL)
- A committee at IBM developed PL/1 based in
the following principles - Programmers time is an important asset and
should not be wasted. - There is a unity in programming which current
division between scientific and commercial
languages did not reflect.
59 FORTRAN 0 FORTRAN I(1957)
COBOL(1960) ALGOL 58 FORTRAN
II ALGOL 60 FORTRAN IV PL/1(1964)
BASIC FORTRAN 66
FORTRAN 77 FORTRAN 90
60PROGRAMMING LANGUAGE 1 (PL/1) (Cont.)
- Pl/1 combined ideas from Fortran, Algol, and
COBOL -
- FORTRAN parameter passing mechanism,
independently compiled subprograms, formatted
input/output and COMMON blocks. -
- ALGOL Block structure and structured
statements. -
- COBOL record input/output,, PICTURE type
declaration, and heterogeneous data structures. -
- From elsewhere list processing concepts,
control structures and methods for storage
management, exception handling by means of
ON-conditions and concurrent execution of tasks
(multi-tasking).
61Example of a PL/1 program
- PROCEDURE OPTIONS (MAIN)
- / Program to find the mean of n numbers and the
number of values greater than the mean / - GET LIST (N)
- IF N gt 0 THEN BEGIN
- DECLARE MEAN, A(n) DECIMAL FLOAT,
- SUM DEC FLOAT INITIAL(0), NUMBER FIXED INITIAL
(0) - GET LIST (A)
- DO I 1 TO N
- SUM SUM A(1)
- END
- MEAN SUM/N
- DO I 1 TO N
- IF A(I) gt MEAN THEN
- NUMBER NUMBER 1
- END
- PUT LIST (MEAN, MEAN, NUMBER GRATER THAN
MEAN, NUMBER) - END
62BASIC (Beginners All-purpose Symbolic
Instruction Code)
- It was originally designed at Dartmouth College
by John Kemeny and Thomas Kurtz in the mid-1960s.
63 FORTRAN 0 FORTRAN I(1957)
COBOL(1960) ALGOL 58 FORTRAN
II ALGOL 60 FORTRAN IV
PL/1(1964) FORTRAN 66
BASIC(mid 60s) FORTRAN 77
FORTRAN 90
64Main Features
- Variables cannot be declared and are single
letters. - Variables are initialized to zero
- Easy to learn and use.
- It was interactive with commands as NEW to create
a program or LIST, RUN, and SAVE.
65Example of BASIC program
- 10 REM THIS IS A BASIC PROGRAM FOR FINDING THE
MEAN - 20 DIM A(99)
- 30 INPUT N
- 40 FOR I 1 TO N
- 50 INPUT A(I)
- 60 LET S S A(I)
- 70 NEXT I
- 80 LET M S/N
- 90 LET K 0
- 100 FOR I 1 TO N
- 110 IF A(I) lt M THEN 130
- 120 LET K K 1
- 130 NEXT I
- 140 PRINT MEAN IS, M
- 150 PRINT NUMBER GREATER THAN MEAN IS, K
- 160 STOP
- 170 END
66 ALGOL
COBOL ALGOL 68 ALGOL W
PL/1
PASCAL ADA
67Pascal
- It was designed by Niklaus Wirth.
- A teaching language
- The language most used in the 1970s
- Include run time environment (code, static data,
stack ? ? heap) - It uses the concept of static array like in
Fortran. - New data types(define by the user) can be built
up from primitive data types.
68Run time environment for Pascal C Ada Java
Object code
Static Data
Stack
Heap
69Example of a Pascal Program
- (Pascal program for finding the mean)
- Program main (input, output)
- type intlist array 1 . . 99 of integer
- var
- a intlist
- i, n, number integer
- sum, mean real
- (main program starts here )
- begin
- number 0
- sum 0
- readln (n)
- for I 1 to n do
- begin
- readln(ai)
- sum sum ai
- end
- mean sum/n
- for I 1 to n do
70Example for temporary expression x i (I
J) (I/J f( J ))
(Stack Pointer)
Outgoing results
SP
Result of I / K
Result of I J
Address of x i
Activation Record
Local Variables
Formal Parameter
RA
(Stack Frame)
Static Link
Dynamic Link
SF
71Some comments of N. Wirth about language design
- Power of a language lies in its regularity and
not in its abundant of Features - Character of a language is defined by what it
prevents more than by what it allows to be
expressed
72C
- Implemented by Dennis Ritchie in 1972
- system programming
- c 1972
- c 1989 (ANSI)
- c 1992 (ISO)
73 ALGOL 60 ALGOL W(1966) ALGOL68 SIMULA
67 BCPL PASCAL C(1972)
MODULA C ADA(83)
OBERON Eiffel(90)
ADA(95) JAVA
74An Example of a C Program
- /C program for finding the mean/
- main()
- float a100, mean, sum
- / the array a has 100 elements a0, .. a99
/ - int n, i, number
- scanf(d, n)
- for( i 0 i lt n i)
- scanf(f, a i )
- sum 0.0
- for( i 0 i lt n i)
- sum a i
- mean sum / n
- number 0
- for( i 0 i lt n i)
- if( a i gt mean)
- number
-
- printf( MEAN f \n, mean)
- printf(NUMBER OVER MEAN d\n, number)
No nested procedures are allowed
75Activation record
(Stack Pointer) SP
Sum
Local
List4
Local
Local
List3
List2
Local
void sub(float total, int part ) int
List5 float sum
Local
List1
List0
Local
Part
Parameter
Total
Parameter
Dynamic Link
Return Address
(Stack Frame) SF
76Bibliography Concepts of Programming Languages,
7th edition, Robert Sebesta, Addison-Wesley 2006,
ISBN 0-321-33025-0. L.B. Wilson and R.G.
Clark, Comparative Programming Languages, 3rd
edition, Addison-Wesley, 2001. http//www.techiwa
rehouse.com/Cobol/Cobol_Tutorial.html2 Jiehong
Li and Rona Abraham notes. Â M. Donald MacLaren,
Exception handling in PL/I Proceedings of an ACM
conference on Language design for reliable
software ,Raleigh, North Carolina pp. 101 104,
1977