1 / 84

COP 4020 Programming Languages I

COP 4020 Programming Languages I. Euripides Montagne University of Central Florida (Fall 2012). Outline. Course Organization Why studying programming languages?. COP 4020 Programming Language I. Who am I and where to find me?. Instructor: Euripides Montagne Tele.: (407) 823 -2684

milo
Download Presentation

COP 4020 Programming Languages I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP 4020 Programming Languages I Euripides Montagne University of Central Florida (Fall 2012) COP 4020 Programming Language 1

  2. Outline • Course Organization • Why studying programming languages? COP 4020 Programming Language 1

  3. COP 4020 Programming Language I Who am I and where to find me? Instructor:Euripides Montagne Tele.:(407) 823-2684 email: eurip@eecs.ucf.edu Office hours: MTWR from 1:00 p.m. to 2:30 p.m. (HEC 217) COP 4020 Programming Language 1

  4. COP 4020 Programming Language ICourse information Lecture meetings: MW 3:00 p.m. – 4:15 p.m.(CLI 320) Web page:http://www.cs.ucf.edu/courses/cop4020/fall2012/ COP 4020 Programming Language 1

  5. COP 4020 Programming Language ICourse outline Course Outline: This course is designed to provide a fundamental understanding of the design and implementation issues surrounding programming languages and their running environment. Students will be exposed different models of computer programming during the course, including: concurrent programming model, declarative computation model and relational model. Course Topics: History of programming languages. Fundamental concepts of programming languages, such as scope, binding, abstraction, encapsulation, typing etc. Run time environment. Lambda calculus. Declarative computation model. Concurrent programming model and message passing. Operational semantics, axiomatic semantics, and denotational semantics. Relational computation model. Prerequisites: COP 3530C COP 4020 Programming Language 1

  6. COP 4020 Programming Language I Course outline (continued) Grading Policy:(15%) Exam #1 (15%) Exam #2 (15%) Presentation (25%) Final Exam (30%) Programming projects. “Late assignments will not be accepted” COP 4020 Programming Language 1

  7. COP 4020 Programming Language ICourse outline (continued) Material: Required textbook: Concepts, Techniques, and Models of Computer Programming, P. van Roy and S. Haridi, MIT press, 2004, ISBN: 0-262-22069-5. Other recommended source: Concepts of Programming Languages, 9th Edition, Robert W. Sebesta, Addison Wesley, 2010, ISBN: 0-13-607347-6 The text will be supplemented with additional notes that will be provided for you via the course web site: http://www.cs.ucf.edu/courses/cop4020/fall2012/ COP 4020 Programming Language 1

  8. COP 4020 Programming Language I Who is your TA? TA: Bo Kang Email: buptkang@gmail.com Office hours: TBA Office: HEC 238 COP 4020 Programming Language 1

  9. UNIVERSITY OF CENTRAL FLORIDA Lecture 1History of Programming Languages COP 4020 Programming Language 1

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

  11. ASSEMBLERS The earliest programming languages were oriented to control the behavior of computers. They reflected the structure of the underlying machine. This view point change mainly for two reasons: 1.- What was easy for a machine to reason about was not necessarily easy for a human being to reason about. 2.- The number of different kinds of machines( architectures) increased and the need arose for a common programming language with which to program all of them. COP 4020 Programming Language 1

  12. 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. COP 4020 Programming Language 1

  13. PUNCH CARD COP 4020 Programming Language 1

  14. 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 COP 4020 Programming Language 1

  15. 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 COP 4020 Programming Language 1

  16. 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. COP 4020 Programming Language 1

  17. 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) COP 4020 Programming Language 1

  18. FORTRAN 77: • IF-THEN-ELSE • Offers features that are common to modern programming languages: • Records • Modules • Pointers • Subprograms can be recursive FORTRAN 90: COP 4020 Programming Language 1

  19. FORTRAN 95: • FOR ALL construct to aid vectorization FORTRAN 2003: • Object-oriented programming • IEEE floating-point arithmetic COP 4020 Programming Language 1

  20. 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 COP 4020 Programming Language 1

  21. 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>, … COP 4020 Programming Language 1

  22. 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 COP 4020 Programming Language 1

  23. 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 COP 4020 Programming Language 1

  24. Implementing FORTRAN 77 SubprogramsActivation Record COP 4020 Programming Language 1

  25. 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 Programming Language 1

  26. Return address Local variables Parameters FORTRAN 77 Activation Record Format COP 4020 Programming Language 1

  27. 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 Programming Language 1 C

  28. ALGOL (ALGOrithmic Language) ALGOL was developed 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 too much additional explanation. • It should be mechanically translated into machine code. COP 4020 Programming Language 1

  29. ALGOL 58 ALGOL 60 ALGOL 68 ALGOL W SIMULA 67 PASCAL COP 4020 Programming Language 1

  30. 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: COP 4020 Programming Language 1

  31. 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 Programming Language 1

  32. 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. COP 4020 Programming Language 1

  33. 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; COP 4020 Programming Language 1

  34. ALGOL 60 ALGOL W(1966) ALGOL68 SIMULA 67 BCPL PASCAL C MODULA C++ ADA(83) OBERON Eiffel(90) ADA(95) JAVA COP 4020 Programming Language 1

  35. 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) COP 4020 Programming Language 1

  36. 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 Programming Language 1

  37. 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 were 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. COP 4020 Programming Language 1

  38. 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 Programming Language 1

  39. 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 Programming Language 1

  40. 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 Programming Language 1

  41. 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 Programming Language 1

  42. 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 Programming Language 1

  43. 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 Programming Language 1

  44. 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 Programming Language 1

  45. 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 Programming Language 1

  46. 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 Programming Language 1

  47. 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 Programming Language 1

  48. 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 Programming Language 1

  49. 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 Programming Language 1

  50. 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 Programming Language 1

More Related