cs 403 programming language theory class 2 - august 29, 2000
TRANSCRIPT
![Page 1: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/1.jpg)
CS 403
Programming Language Theory
Class 2 - August 29, 2000
![Page 2: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/2.jpg)
SyllabusTexts: Sebesta: most of the content & theoryEverybody has a copy?
Meyers: specific applications to C++ CDBookstore is getting the CD in…
![Page 3: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/3.jpg)
Homework Assignment
List all the languages you have easy access to now. Engineering labs Bama Your home PC, if relevant Other computers…
Be sure to note the different implementations of each language.Due today. Turn it in now.Outside write: Name, Section 1 or 2
![Page 4: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/4.jpg)
Homework Assignment #2 (1)Consider this program:
#include <stdio.h> main() {
int i;printf(“Value of i: %d, %o, %x, %u, \n %c, %f, %ld\
n", i,i,i,i,i,i,i);i = 42;printf(“Value of i: %d, %o, %x, %u, \n %c, %f, %ld\
n", i,i,i,i,i,i,i);
}
![Page 5: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/5.jpg)
Homework Assignment #2 (2)
Compile and run (on 4 C compilers, including cc and gcc on UNIX)…Print your program and the executions, identified by compiler. Explain the output (about 1-2 pages) What does ‘printf’ do, and what do the ‘%’
commands do? Why the different but consistent output
values for the same variable? What differences do you note across
compilers?
Turn in Tuesday, Sept 5th
![Page 6: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/6.jpg)
Reading QuizName one language in chapter 2 you hadn’t heard of before, and one characteristic of that language.After you’ve written your answer, draw a line & confer with your table-mates. Correct your answer if necessary.We won’t take this up today. (I’ve already got enough to grade!)
![Page 7: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/7.jpg)
Primary Influences on
Language Design
• Computer architecture
• Programming methodologies
![Page 8: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/8.jpg)
Computer Architecture
We use imperative languages,
at least in part, because we
use von Neumann machines.
Other architectures influence
other languages, i.e., LISP
machines, …
![Page 9: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/9.jpg)
Programming Methodologies• 1950s and early 1960s: Simple
applications; worry about machine efficiency
• Late 1960s: People efficiency became important; readability, better control structures
• Late 1970s: Data abstraction• Middle 1980s: Object-oriented
programming
![Page 10: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/10.jpg)
Language Categories1. Imperative
2. Functional
3. Logic
4. Object-oriented (closely
related to imperative)
![Page 11: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/11.jpg)
Language Design Trade-Offs1. Reliability versus cost of
execution
2. Writability versus readability
3. Flexibility versus safety
![Page 12: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/12.jpg)
Implementation Methods1. Compilation
• Translate high-level program to machine code
• Slow translation• Fast execution
2. Pure interpretation• No translation• Slow execution• Becoming rare
3. Hybrid implementation systems• Small translation cost• Medium execution speed
![Page 13: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/13.jpg)
Programming EnvironmentsThe collection of tools used in software development1. UNIX – An old operating system and tool
collection2. Borland C++ – A PC environment for C
and C++3. Smalltalk –A language processor/
environment4. Microsoft Visual C++ – A large, complex
visual environment
![Page 14: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/14.jpg)
Chapter 2: Evolution of Programming Languages (1)
Plankalkül - 1945Pseudocodes - 1949Laning and Zierler System - 1953FORTRAN:
I - 1957; II - 1958; IV - 1960-62; 77 - 1978; 90 - 1990
![Page 15: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/15.jpg)
Language Evolution(2)LISP - 1959
ALGOL 58 - 1958;
60 - 1960
COBOL - 1960
BASIC - 1964
PL/I - 1965
![Page 16: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/16.jpg)
Language Evolution (3): Early Dynamic Languages
SIMULA 67 - 1967
ALGOL 68 - 1968
Pascal - 1971
C - 1972
Prolog - 1972
Ada - 1983
Smalltalk - 1972-80
C++ - 1985
Java - 1995
![Page 17: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/17.jpg)
Plankalkül - 1945Never implemented
Advanced data structures floating point, arrays, records
Invariants
Notation: A(7) := 5 * B(6) | 5 * B => A V | 6 7 (subscripts) S | 1.n 1.n (data types)
![Page 18: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/18.jpg)
Pseudocodes - 1949Before pseudocodes machine codesWhat’s wrong with machine code? Poor readability Poor modifiability Expressions are tedious Machine weaknesses: no indexing,
floating point, ...
![Page 19: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/19.jpg)
Pseudocodes:Short Code ‘49 Expressions were coded, left to
right
Speedcoding ‘54 Two weeks of programming
few hours! Automatically increment the
instruction counter
![Page 20: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/20.jpg)
FORTRAN 0 - 1954
New IBM 704 Index registers Floating point in hardware
Environment of development:1. Computers were small and unreliable
2. Applications were scientific
3. No programming methodology or tools
4. Machine efficiency was most important
![Page 21: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/21.jpg)
FORTRAN 0 / I - 1957Impact of environment on design:1. No need for dynamic storage
2. Need good array handling and counting loops
3. No string handling, decimal arithmetic, or powerful input/output (commercial stuff)
![Page 22: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/22.jpg)
FORTRAN I - 1957First implemented version of FORTRAN
Names could have up to six characters
Posttest counting loop (DO)
Formatted I/O
User-defined subprograms
Three-way selection statement (arithmetic IF)
No data typing statements
![Page 23: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/23.jpg)
FORTRAN I Features (cont.)No separate compilation
Compiler released in April 1957, after 18 worker/years of effort.
Programs larger than 400 lines rarely compiled correctly, mainly due to poor reliability of the 704 hardware.
Code was very fast
Quickly became widely used
![Page 24: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/24.jpg)
FORTRAN II - 1958Independent compilation
Fix the bugs
![Page 25: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/25.jpg)
FORTRAN IV - 1960-62Explicit type declarations
Logical selection statement
Subprogram names could be parameters
ANSI standard in 1966
![Page 26: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/26.jpg)
FORTRAN 77 - 1978Character string handling
Logical loop control statement
IF-THEN-ELSE statement
![Page 27: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/27.jpg)
FORTRAN 90 (“9X”) - 1990ModulesDynamic arraysPointersRecursionCASE statementParameter type checking
![Page 28: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/28.jpg)
FORTRAN Evaluation:
Dramatically changed forever the way computers are used!
![Page 29: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/29.jpg)
LISP - 1959LISt Processing language (MIT, McCarthy)
AI research needed a language that:
1. Process data in lists (vs. arrays)
2. Symbolic computation (vs. numeric)
Only two data types: atoms and lists
Syntax is based on lambda calculus
![Page 30: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/30.jpg)
LISP (2)Pioneered functional programmingNo need for variables or assignmentControl via recursion and conditional expressionsStill the dominant language for AICOMMON LISP and Scheme are contemporary dialects of LISPML, Miranda, and Haskell are related languages
![Page 31: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/31.jpg)
ALGOL 58 - 1958Environment of development:
1. FORTRAN had (barely) arrived for IBM 70X
2. Many other languages were being developed, all for specific machines
3. No portable language; all were machine-dependent
4. No universal language for communicating algorithms
![Page 32: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/32.jpg)
ALGOL 58 (2)ACM and GAMM met for four days for design
Goals of the language:
1. Close to mathematical notation
2. Good for describing algorithms
3. Must be translatable to machine code
![Page 33: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/33.jpg)
ALGOL 58 (3)Language Features:
Concept of type was formalized
Names could have any length
Arrays could have any number of subscripts
Parameters were separated by mode (in & out)
Subscripts were placed in brackets
Compound statements (begin ... end)
Semicolon as a statement separator
Assignment operator was :=
if had an else-if clause
![Page 34: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/34.jpg)
ALGOL 60 - 1960Modified ALGOL 58 at 6-day meeting in Paris
New Features: Block structure (local scope) Two parameter passing methods Subprogram recursion Stack-dynamic arrays Still no i/o and no string handling
![Page 35: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/35.jpg)
ALGOL 60 (2)
Successes:
It was the standard way to publish algorithms for over 20 years
All subsequent imperative languages are based on it
First machine-independent language
First language whose syntax was formally defined (BNF)
![Page 36: CS 403 Programming Language Theory Class 2 - August 29, 2000](https://reader033.vdocuments.mx/reader033/viewer/2022051401/56649e9e5503460f94b9f281/html5/thumbnails/36.jpg)
ALGOL 60 (3)Never widely used, especially in U.S.Reasons:
1. No I/O and the character set made programs nonportable
2. Too flexible--hard to implement3. Entrenchment of FORTRAN4. Formal syntax description5. Lack of support of IBM