Class 2 History of Programming Languages FORTRAN LISP









































![Example for “temporary expression” x[ i ] = (I + J) * (I/J + Example for “temporary expression” x[ i ] = (I + J) * (I/J +](https://slidetodoc.com/presentation_image_h2/1642690dee312902cf5d8bb8f5ceb334/image-42.jpg)


![SP void sub(float total, int part ) { int List[5]; float sum; … } SP void sub(float total, int part ) { int List[5]; float sum; … }](https://slidetodoc.com/presentation_image_h2/1642690dee312902cf5d8bb8f5ceb334/image-45.jpg)


- Slides: 47

Class 2: History of Programming Languages • • • FORTRAN LISP ALGOL SIMULA COBOL PL/1 BASIC PASCAL C The so called High Level Programming Languages started their development in the mid 50 s.

FORTRAN (FORmula. TRANslation) • Fortran was design to develop scientific applications on the IBM 704(with punched card inputs) computer and the major role in its design was run-time efficiency.

Main 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

Main 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

Example 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 FORMAT (I 2) READ (1, 10) (A(I), I=1, N) FORMAT (6 F 10. 5) SUM = 0. 0 DO 15 I=1, N SUM = SUM + A(I) MEAN = SUM/FLOAT(N) NUMBER = 0 DO 20 I=1, N IF (A(I). LE. MEAN 0 GOTO 20 NUMBER = NUMBER + 1 CONTINUE WRITE (2, 250 MEAN, NUMBER FORMAT (8 H MEAN = , F 10. 5, 5 X, 20 H NUMBER OVER MEAN = , I 5) STOP END.

Development: • 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)

FORTRAN 90: • Offers features that are common to modern programming languages: • Records • Modules • Pointers

FORTRAN 0 FORTRAN I(1957) COBOL(1960) FORTRAN II ALGOL 60 FORTRAN IV PL/1(1964) BASIC FORTRAN 66 FORTRAN 77 FORTRAN 90 ALGOL 58

Referencing 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 /<name>/<var or array>, …

Example: COMMON/ Globalvar/X/Y/A(20) program main real X, Y common /BLK/ X, Y statements stop End subroutine sub 1 ( arguments) declarations of arguments real X, Y common /BLK/ X, Y statements return End subroutine sub 2 ( arguments) declarations of arguments real X, Y common /BLK/ X, Y statements return end

Memory layout System data and I/O buffers Code and local data for main program BLK (common block) Code and local data for sub 1 Code and local data for sub 2 System I/O routine

ALGOL (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.

ALGOL 58 ALGOL 60 ALGOL 68 ALGOL W PASCAL SIMULA 67

Major 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:

Major Concepts introduced in ALGOL(2): • Sequence: S 1, S 2, …, Sn • Selection (IF-THEN-ELSE) • Iteration (For I : = 1 step 1 until n do) • First language to introduce recursive procedures.

Why ALGOL 60 did not supersede FROTRAN? • 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.

Example 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 a[1: n]; integer i, number; real sum, mean; for i : = 1 step 1 until n do read(a[i]); sum : = 0. 0; for i : = 1 step 1 until n do sum : = sum + a[i]; mean ; sum/n; number ; = 0; for i : = 1 step 1 until n do if a[i] > mean then number ; = number + 1; write (“MEAN = “, mean, “NUMBER OVER MEAN = “, number); end;

ALGOL 60 ALGOL W(1966) ALGOL 68 SIMULA 67 BCPL PASCAL C MODULA C++ ADA(83) OBERON Eiffel(90) ADA(95) JAVA

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 called by values and by name. § Long real and complex data type were introduced (complex arithmetic)

The 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(B 6700)

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.

• INCLUDE RECURSION AND STACK MECHANISM

COBOL (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

Main features: • • • The language is simple No pointers No user defined types Record data type Self documented

A 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. 17/5/00. 000150 DATE-COMPILED. 000160 SECURITY. LOCAL GROUP

• The environment division: Contain machinedependent 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.

§ 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)V 99. 001700 05 SP-CURRENT-RETURNS PIC 9(4)V 99. 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. 002600 05 FILLER PIC X(6). 002700 05 RT-CURRENT-RETURNS PIC Z, ZZZ. 99. 002800 05 FILLER PIC X(65). 002900 WORKING-STORAGE SECTION. 003000 01 WS-EOF-FLAG PIC X.

• The procedure division: Contains the algorithms necessary to solve the problem. 000900 PROCEDURE DIVISION. 000910 CONTROL-PARAGRAPH. 000920 PERFORM READ-DATA-FILE 000930 PERFORM CALULATE-PRICES 000940 PERFORM PRINT-PRICE-REPORT 000950 STOP RUN.

Example of a COBOL program(Hello world): 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. HELLO-WORLD-PROG. 000030 AUTHOR. TIMOTHY R P BROWN. 000040*The 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.

Example program 2: 000100 ID DIVISION. 000200 PROGRAM-ID. ACCEPT 1. 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 ZZZ 9. 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-SECONDNUMBER. 001800 DISPLAY 'THE TOTAL IS: ', WS-TOTAL. 001900 STOP RUN.

Example 3 Shows some basic commands: 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.

COBOL continues to progress with work being done in the Object-Oriented COBOL standard.

PROGRAMMING LANGUAGE 1 (PL/1) In the early 1960 s 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.

PROGRAMMING 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).

Example 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 > 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). MEAN THEN NUMBER = NUMBER +1; END; PUT LIST (‘MEAN=’, MEAN, ‘NUMBER GRATER THAN MEAN=’, NUMBER); END;

BASIC (Beginner’s All-purpose Symbolic Instruction Code) It was originally designed at Dartmouth College by John Kemeny and Thomas Kurtz in the mid-1960 s.

Main 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.

Example 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) < M THEN 130 120 LET K = K + 1 130 NEXT I 140 PRINT “MEAN IS”, MEAN 150 PRINT “NUMBER GREATER THAN MEAN IS”, K 160 STOP 170 END

ALGOL 68 ALGOL W PASCAL ADA COBOL PL 1

Pascal • • It was designed by Niklaus Wirth. A teaching language The language most used in the 1970 s Include run time environment (code, static data, stack … heap) • It uses the concept of static array like in Frotran. • New data types(define by the user) can be built up from primitive data types.

Example 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 stars here *) begin number : = 0; sum : = 0; readln (n); for I : = 1 to n do begin readln(a[i]); sum : = sum + a[i] end; mean : = sum/n; for I : = 1 to n do if (a[i] > mean) then number : = number + 1; writeln (‘the number over mean is: ‘, number) end.
![Example for temporary expression x i I J IJ Example for “temporary expression” x[ i ] = (I + J) * (I/J +](https://slidetodoc.com/presentation_image_h2/1642690dee312902cf5d8bb8f5ceb334/image-42.jpg)
Example for “temporary expression” x[ i ] = (I + J) * (I/J + f( J )) SP Outgoing results Result of I / K Result of I + J Address of x [ i ] Local Variables Formal Parameter RA SF Static Link Dynamic Link

C Implemented by Dennis Ritchie in 1972 system programming c – 1972 c – 1989 (ANSI) c – 1992 (ISO)

An Example of a C Program: /*C program for finding the mean*/ main(){ float a[100], mean, sum; /* the array a has 100 elements – a[0], . . a[99] */ int n, i, number; scanf(“%d”, &n); for( i = 0; i < n; ++i) scanf(“%f”, &a[ i ]); sum = 0. 0; for( i = 0; i < n; ++i) sum += a[ i ]; mean = sum / n; number = 0; for( i = 0; i < n; ++i){ if( a[ i ] > mean) number++; } printf(“ MEAN = %f n”, mean); printf(“NUMBER OVER MEAN = %dn”, number); } * No nested procedures are allowed
![SP void subfloat total int part int List5 float sum SP void sub(float total, int part ) { int List[5]; float sum; … }](https://slidetodoc.com/presentation_image_h2/1642690dee312902cf5d8bb8f5ceb334/image-45.jpg)
SP void sub(float total, int part ) { int List[5]; float sum; … } Local Sum Local List[4] Local List[3] Local List[2] Local List[1] Local Parameter Part Parameter Total Dynamic Link SF List[0] Return Address

Run time environment for: Object code C Pascal Static Data Ada Algol Java Stack Heap

Bibliography L. B. Wilson and R. G. Clark, “Comparative Programming Languages”, 3 rd edition, Addison-Wesley, 2001. http: //www. techiwarehouse. com/Cobol_Tutorial. ht ml#2 Jiehong Li and Rona Abraham notes. M. Donald Mac. Laren Exception handling in PL/I Proceedings of an ACM conference on Language design for reliable software Raleigh, North Carolina pp. 101 – 104, 1977