Course Goals

Course Goals

Programming Languages History CMSC 4023 Chapter 2 2. History Programming languages are designed to satisfy two objectives. 2.1. People need to be able to write instructions that implement computational procedures and algorithms in a programming language. 2.2. Programming languages need to express mathematical concepts and mathematical notation. • The development of programming languages has been influenced by the development of the electronic hardware that executes computer programs. • Some developers of programming languages have attempted to define a language that can be used to define an algorithm without exactly specifying the sequence of instructions for the algorithm. 2.1. Early History: The First Programmer 2.1.1. John von Neumann (1940 – 1950) Before the advent of John von Neumann results were computed using telephone switchboard machinery. If one desired a different computation, one rearranged the “switchboard.” John von Neumann conceived the idea that instructions and data should be stored in memory. A central processing unit should execute instructions fetched from memory. Thus the von Neumann bottleneck was born. Execution was limited by the pathway from memory to the CPU. Instructions could not be executed any faster than they could be fetched from memory. Figure 1. Von Neumann Architecture 2.1.2. Charles Babbage and Ada Lovelace (1830 – 1840) Charles Babbage conceived the idea of a difference engine implemented entirely using mechanical parts. He failed in his goal because sufficiently accurate machining was not available in his era. However, the concept was proven by the London Science Museum. 1 Programming Languages History CMSC 4023 Chapter 2 Based on Babbage's original plans, the London Science Museum constructed a working Difference Engine No. 2 from 1989 to 1991, under Doron Swade, the then Curator of Computing. Ada Lovelace developed algorithms for the difference engine and, later, for the analytical engine. It is clear from her notes that she understood both the concept of programs and the essential symbolic nature of programs. Figure 2. The Difference Engine constructed by the London Science Museum 2.2. The 1950s: The First Programming Languages 2.2.1. Machine language Machine language is the language accepted by the central processing unit (CPU) or, in the example below, a virtual machine interpreter. It consists entirely of 0s and 1s. 8 8 16 opcode operand 1 operand 2 0 7 8 15 16 31 Figure 3. Anatomy of a P-Code Instruction iaddr P-Code Operand 1 Operand 2 Comment 0 02 00 0005 Start procedure addlocal Allocate storage for variable i and the stack mark 1 02 01 0003 Reserve 3 elements for the computation stack 2 29 00 0005 Load the address of variable i in preparation to store a value. 3 2F 00 0005 Load the value of variable i 4 2A 04 0001 Load an integer constant 1. 5 0B Add the two integers on top of the stack. 6 32 04 0000 Assign the sum to variable i. 7 04 00 0000 Return to the caller 8 02 00 0004 Start program locals Allocate storage for the stack mark 2 Programming Languages History CMSC 4023 Chapter 2 9 02 01 0005 Reserve 5 elements for the computation stack Figure 3. Annotated Machine P-Code listing of program locals iaddr P-Code Operand 1 Operand 2 Comment A 03 0 0000 Allocate storage for procedure addlocals stack mark B 00 00 0000 Call procedure addlocal. C 04 00 0000 Return to the caller D 03 00 0000 Execution starts here. Create program main's stack mark. D 00 00 0008 Call program local F 28 00 0000 Stop Figure 3. Annotated Machine P-Code listing of program locals 2.2.2. Assembly language Assembly language is a symbolic form of machine language. Mnemonics are assigned to operations, registers, and other values. Variables are referenced by their relative address. iaddr P-Code Operand 1 Operand 2 Comment 0 ent sp 5 Start procedure addlocal Allocate storage for variable i and the stack mark 1 ent ep 3 Reserve 3 elements for the computation stack 2 lda 0 5 Load the address of variable i in preparation to store a value. 3 lvi 0 5 Load the value of variable i 4 ldc i 1 Load an integer constant 1. 5 adi Add the two integers on top of the stack. 6 sti i Assign the sum to variable i. 7 rtn p Return to the caller 8 ent sp 4 Start program locals Allocate storage for the stack mark 9 ent ep 5 Reserve 5 elements for the computation stack A mst 0 Allocate storage for procedure addlocals stack mark B cup 0 0 Call procedure addlocal. C rtn p Return to the caller D mst 0 Execution starts here. Create program main's stack mark. D cup 0 8 Call program local F stp Stop Figure 4. Annotated Assembly P-Code listing of program locals 3 Programming Languages History CMSC 4023 Chapter 2 program locals; procedure addlocal; var i:integer; begin{addlocal} i:=i+1 end{addlocal}; begin{locals} addlocal end{locals}. Figure 5. Program local. 2.2.3. FORTRAN • First High Level Programming Language • FORTRAN – FORmula TRANslation • John Backus 1954 – 1957 • Scientific and computational programming • Efficiency • Storage allocation is not stack-based but statically allocated by the compiler for efficiency. • FORTRAN II, FORTRAN IV, FORTRAN66, FORTRAN77, FORTRAN90 ******ERRORS INDUCED BY ARITHMETIC OPERATONS ON SAMLL NUMBERS REAL SUM6,SUM7,SUM8,DIF6,DIF7,DIF8,SUMINF * OPEN(6,FILE='PRN') SUM6=.9*(1.-0.1**6)/0.9 SUM7=.9*(1.-0.1**7)/0.9 SUM8=.9*(1.-0.1**8)/0.9 ******COMPUTER SUM OF INFINITE TERMS SUMINF=0.9/(1.0-0.1) ******COMPUTE DIFFERENCES BETWEEN FINITE & INFINITE SUMS DIF6 = SUMINF - SUM6 DIF7 = SUMINF - SUM7 DIF8 = SUMINF - SUM8 WRITE(6,*) 'INFINITE SUM = ', SUMINF WRITE(6,*) 'SUM6 = ', SUM6, ' INFINITE SUM - SUM6 = ', DIF6 WRITE(6,*) 'SUM7 = ', SUM7, ' INFINITE SUM - SUM7 = ', DIF7 WRITE(6,*) 'SUM8 = ', SUM8, ' INFINITE SUM - SUM8 = ', DIF8 STOP END Figure 6. A Fortran program 4 Programming Languages History CMSC 4023 Chapter 2 2.2.4. COBOL • COmmon Business-Oriented Language • U. S. Department of Defense (1959 – 1960) and Admiral Grace Hopper • Large-scale record-keeping and other business applications • A goal of the language designers was for coded programs to be easily read and understood (a failure). • Business schools often offer courses on COBOL programming, but computer science departments generally do not.) • The language is extremely wordy • Sophisticated algorithms are difficult to program in COBOL • Innovations include the record structure and separation of data declarations from executable portions of the program • "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense" - Edsger Dijkstra 1975 IDENTIFICATION DIVISION. Program-Id. Hello-World. * ENVIRONMENT DIVISION. * DATA DIVISION. * PROCEDURE DIVISION. Para1. DISPLAY "Hello, world.". * Stop Run. Figure 7. A COBOL Program 2.2.5. ALGOL60 • Developed by an international Committee chaired by W. L. van der Poel including John Backus, Edsger Dijkstra, Peter Naur, and A. van Wijngaarden • An Historic Event • Grammar – Backus Naur Form (BNF) • Descendents include Pascal, C, Modula-2, and Ada • Introduced many concepts including o free-format o structured statements o begin-end blocks o type declarations o recursion o pass by-value parameters o stack-based runtime environment for block-structured languages 5 Programming Languages History CMSC 4023 Chapter 2 begin integer i, n, b, c; real t, p, q, m, s; n:= read; c:=0; p:=0; q:=0; for i:=1 step 1 until n do begin t:=read; b:=read; p:=p+t; q:=q+t^2; if t>=7 and b>=1 then c:=c+1 end; m:=p/n; s:=sqrt(q/n-m^2); print(c); print(m); print(s) end Figure 8. An Algol Program 2.2.6. LISP • Developed at MIT in the late 1950s by John McCarthy • Functional programming • Artificial intelligence • Variants include MacLisp, Franz Lisp, Common LISP, and Scheme • Based on a uniform data structure, the S-expression • Introduced garbage collection • Conceptually different than the von Neumann architecture and inherently inefficient. • Special purpose architectures have been developed to execute Lisp programs • Recursion (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1))))) Figure 9. A Lisp Function 6 Programming Languages History CMSC 4023 Chapter 2 2.2.7. APL • A Programming Language • Ken Iverson at Harvard – IBM in the late 1950s and early 1960s • A language for programming mathematical computations, particularly those involving arrays and matrices • APL included a large number of operators that allow most iterations to be performed completely automatically. • Drawbacks include no structuring, and its use of the Greek alphabet. • APL was extremely difficult to read • Special IBM character set keyboard The following program finds all prime numbers from 1 to R (presuming an index origin of 1). In both time and space, the calculation is O(R2). From right to left, this means: 1. creates a vector containing integers from 1 to R (if R = 6 at the beginning of the program, is 1 2 3 4 5 6) 2. Drop first element of this vector ( function), i.e. 1. So is 2 3 4 5 6 3. Set R to the vector ( , assignment primitive) 4. Generate outer product of R multiplied by R, i.e. a matrix which is the multiplication table of R by R ( function) 5. Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix ( , set inclusion function), i.e. 0 0 1 0 1 6. Logically negate the values in the vector (change zeros to ones and ones to zeros) ( , negation function), i.e.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us