760 likes | 943 Views
UNIVERSITY OF CENTRAL FLORIDA. Lecture 2 History of Programming Languages. Class 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.
E N D
UNIVERSITY OF CENTRAL FLORIDA Lecture 2History of Programming Languages
Class 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.
FORTRAN (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.
PUNCH CARD COP 4020 Programmin Language 1
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 5 FORMAT (I2) READ (1,10) (A(I), I=1, N) 10 FORMAT (6F10.5) SUM = 0.0 DO 15 I=1, N 15 SUM = SUM + A(I) MEAN = SUM/FLOAT(N) NUMBER = 0 DO 20 I=1, 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) 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 77: • IF-THEN-ELSE • Offers features that are common to modern programming languages: • Records • Modules • Pointers • Subprograms can be recursive FORTRAN 90:
FORTRAN 95: • FOR ALL construct to aid vectorization FORTRAN 2003: • Object-oriented programming • IEEE floating-point arithmetic COP 4020 Programmin Language 1
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
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>, <var or array>, <var or array>, …
Example: 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 statements return end
FORTRAN 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
Implementing FORTRAN 77 SubprogramsActivation Record COP 4020 Programmin Language 1
FORTRAN 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. COP 4020 Programmin Language 1
Return address Local variables Parameters FORTRAN 77 Activation Record Format COP 4020 Programmin Language 1
Return address Return address Return address Local variables Local variables Local variables Parameters Parameters Parameters FORTRAN 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 MAIN Local variables A Data B C MAIN A Code B COP 4020 Programmin Language 1 C
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 SIMULA 67 PASCAL COP 4020 Programmin Language 1
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: S1,S2,…,Sn • Selection (IF-THEN-ELSE) • Iteration (For I:= 1 step 1 until n do) • First language to introduce recursive procedures. COP 4020 Programmin Language 1
Why 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.
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; end;
ALGOL 60 ALGOL W(1966) ALGOL68 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 passed 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 (B6700) COP 4020 Programmin Language 1
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.
Run-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. COP 4020 Programmin Language 1
Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real; procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 *) COP 4020 Programmin Language 1
Working space for Procedure P0, the main program Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real; procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P0, the main program Memory for variable R1 Memory for variable T1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real; procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real; procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Memory for variable X Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Memory for variable X Pointer to variable T1 Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Memory for variable X Pointer to variable T1 Indirect pointer to elements of A1 Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Memory for variable X Pointer to variable T1 Indirect pointer to elements of A1 Reference to procedure P2 Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P2 Working space for Procedure P1 Reference to procedure P2 Pointer to variable T1 Memory for variable X Indirect pointer to elements of A1 Pointer to elements of A1 Working space for Procedure P0, the main program Memory for variable T1 Reference to procedure P1 Memory for variable R1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Reference to procedure P2 Indirect pointer to elements of A1 Pointer to variable T1 Memory for variable X Memory for variable R1 Pointer to elements of A1 Reference to procedure P1 Working space for Procedure P0, the main program Memory for variable T1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Memory for variable X Pointer to variable T1 Indirect pointer to elements of A1 Reference to procedure P2 Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Working space for Procedure P0, the main program Reference to procedure P1 Program Stack program P0; var R1, T1: real; A1: array[0:5,0:20] of real; procedure P1( X: real; var T: real; Y: array[0:5,0:20] of real;) procedure P2; var R2, T2: real; A2: array[0:5,0:20] 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 COP 4020 Programmin Language 1
Working space for Procedure P1 Pointer to variable T1 Memory for variable X Indirect pointer to elements of A1 Reference to procedure P2 Working space for Procedure P0, the main program Memory for variable T1 Pointer to elements of A1 Memory for variable R1 Reference to procedure P1 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 COP 4020 Programmin Language 1
FORTRAN 0 Flow-Matic (Grace Hopper-57) FORTRAN I(1957) COBOL(1960) ALGOL 58 FORTRAN II ALGOL 60 FORTRAN IV PL/1(1964) BASIC FORTRAN 66 FORTRAN 77 FORTRAN 90 COP 4020 Programmin Language 1
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
COBOL-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) COP 4020 Programmin Language 1
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 or divisions: Division Name Contains • IDENTIFICATION Program identification. • ENVIRONMENT Type of computer used. • DATA Buffers, constants, work areas. • PROCEDURE The processing (program logic).
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. 5/15/06.000150 DATE-COMPILED.000160 SECURITY. LOCAL GROUP
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.