0% found this document useful (0 votes)
38 views50 pages

UNIT I - Preliminary Concepts Lecture 2 - Evolution of Programming Languages

This document discusses the evolution of programming languages from early machine code programming to modern languages. It describes the limitations of early assembly languages and the development of early high-level languages like FORTRAN and LISP to improve productivity by moving programming to a higher level of abstraction. FORTRAN focused on scientific computing and was influenced by the von Neumann architecture. LISP pioneered functional programming with lists and recursion and influenced the use of dynamic memory allocation. ALGOL aimed to provide a universal, machine-independent language.

Uploaded by

veningston
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views50 pages

UNIT I - Preliminary Concepts Lecture 2 - Evolution of Programming Languages

This document discusses the evolution of programming languages from early machine code programming to modern languages. It describes the limitations of early assembly languages and the development of early high-level languages like FORTRAN and LISP to improve productivity by moving programming to a higher level of abstraction. FORTRAN focused on scientific computing and was influenced by the von Neumann architecture. LISP pioneered functional programming with lists and recursion and influenced the use of dynamic memory allocation. ALGOL aimed to provide a universal, machine-independent language.

Uploaded by

veningston
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 50

Principles of Programming

Languages

UNIT I – Preliminary Concepts


Lecture 2 - Evolution of Programming Languages
19/07/2017 - CSE – D
19/07/2017 - CSE - B

1
Consider a C Language
• No dynamic variables
– All variables are global and static; no malloc(), free()
int i,j,k;
float temperature[100];
void init_temp() {
for (i=0; i<100; i++) {
temperature[i] = 0.0;
}
}
– How to program? How about hash table? binary tree?
Problems: developing scalable, large programs, making errors,
being inflexible, managing storage by programmers, … 2
Outline
• Evolution of Programming Languages (Ch. 2)
– Influences on Language Design (Sec. 1.4)
– Language Categories (Sec. 1.5)
– Programming Domains (Sec. 1.2)

3
The Dawn of Modern Computers
• Early computers (40’s and early 50’s) were
programmed using machine code directly:
– Limited hardware; no Functional programming (FP),
indexing, system software
– Computers more expensive than programmers/users
– Poor readability,
modifiability,
expressiveness
– Describe computation
flows
– Mimic von-Neumann
architecture

4
Von-Neumann Architecture

5
Early Programming
• Programmers have to enter machine code to
program the computer
– Floating point: coders had to keep track of the
exponent manually
– Relative addressing: codes had to be adjusted by
hand for the absolute addresses
– Array subscripting needed
– Something easier to remember than octal opcodes
• Early aids:
– Assembly languages and assemblers: 1-to-1
representation of machine instructions
• Saving programmer time became important …
6
Types of Languages
• Imperative Languages (Eg. FORTRAN)
• Functional Languages (Eg. LISP)
• Logical Languages (Eg. PROLOG)
• Object Oriented languages (Eg. JAVA)

7
Fortran
• First popular high-level programming language
– Computers were small and unreliable
 machine efficiency was most important
– Applications were scientific
 need good array handling and counting loops
• "The IBM Mathematical FORmula TRANslating
System: FORTRAN", 1954: (John Backus at IBM)
– To generate code comparable with hand-written code
using simple, primitive compilers
– Closely tied to the IBM 704 architecture, which had
index registers and floating point hardware
8
Fortran
• Fortran I (1957)
– Names could have up to six characters, formatted I/O,
user-defined subprograms, no data typing
– No separate compilation (compiling “large” programs
– a few hundred lines – approached 704 MTTF)
– Highly optimize code with static types and storage
• Later versions evolved with more features and
platform independence
– Almost all designers learned from Fortran and Fortran
team pioneered things such as scanning, parsing,
register allocation, code generation, optimization

9
Program Compilation
Process

10
FORTRAN and von-Neumann Arch.
• FORTRAN, and all other imperative languages,
which dominate programming, mimic von-
Neumann architecture
– Variables  memory cells
– Assignment statements  data piping between
memory and CPU
– Operations and expressions  CPU executions
– Explicit control of execution flows
– Efficient mapping between language and HW
 efficient execution performance, but limited by
von Neumann bottleneck

11
Von-Neumann bottleneck
• The term is named for John von Neumann, who
developed the theory behind the architecture of
modern computers.
• Earlier computers were fed programs and data for
processing while they were running.
• The von Neumann bottleneck is a limitation on
throughput caused by the standard personal computer
architecture.
• An instruction fetch and a data operation cannot occur
at the same time because they share a common bus.
12
Pipeline in
Computing

13
FORTRAN Programming Style
• Global view, top down i=0; f=0;
• Program starts from first
executable statement and N
follow a sequential flow i<N
with go-to Y
– Conceptually, a large f = f + c[i]*x[i]; f = 0;
main() including
everything but without
main() declaration, i = i+1;
though FORTRAN has functions
– Match a flow chart with traces

Problems: developing scalable, large programs, making errors,


being inflexible, managing storage by programmers, … 14
Fortran – Example Code
• https://www.jdoodle.com/execute-fortran-onl
ine
- Online Compiler - G95
program sum
REAL X,Y,Z program sum
X = 10 REAL X,Y,Z
Y= 25 READ *, X, Y
Z=X+Y Z=X+Y
PRINT *,"sum of x + y = ", Z PRINT *,"sum of x + y = ", Z
end program sum end program sum

15
Fortran – Factorial of a number

INTEGER NUMBER, FACT, N

PRINT*,'ENTER A POSITIVE INTEGER'


READ*, NUMBER
FACT = 1
DO 100 N = 2, NUMBER, 1
FACT = FACT*N
100 CONTINUE
PRINT*, FACT
STOP
END
16
Fortran – To add a list of numbers
program summation
implicit none
integer :: sum, a
print*, "This program performs
summations. Enter 0 to stop."
sum = 0
do
print*, "Add:"
read*, a
if (a == 0) then
exit
else
sum = sum + a
end if
end do
print*, "Summation =", sum
close(10)
end 17
Top-down Vs. Bottom-up approach
• In Top-Down development, we start with
main function, and then think of the main
steps we need to do, then we break up each
of those steps into their subparts as functions.

• In Bottom-Up programming, we think of the


basic functionality as classes and then the
parts we need and build them. 

18
Functional Programming: LISP
• AI research needed a language to
– Process data in lists (rather than arrays)
– Symbolic computation (rather than numeric)
• John McCarthy of MIT developed LISP (LISt
Processing language) in 1958
• A LISP program is a list:
(+ a (* b c))
– List form  both for input and for function
– Only two data types: atoms and lists

19
LISP
• Example: a factorial function in LISP
(defun fact (x)
(if (<= x 0)
1
(* x (fact (- x 1)))
)
)
• Second-oldest general-purpose programming
language still in use
– Ideas, e.g. conditional expression, recursion, garbage
collection, were adopted by other imperative languages.

20
Example: LISP code

21
LISP code – Computing x y

(defun power (x y)
(if (> y 0)
(* x
(power x (- y 1)))
1))

To call the above function:

(power 2 3)

22
LISP Code – Add list

(defun sum (numbers)


(if (null numbers)
0
(+ (first numbers) (sum
(rest numbers)))))

To call the above function:

(sum '(1 3 2))

23
LISP – Exercises – Assignment 1
Submission Deadline: 2nd Aug, 2017
• Write a function that can add two list to one, such
as (add '(1 2 3) '(4 5 6)) = (5 7 9) (1 2 3)
(2 3 4)
• Write a function to add multiple list  (3 4 5)
(8 7 6)

(14 16 18)
• To calculate the average of a list such as
((1 1 1)
(2 2 2)
(3 3 3))
= (2 2 2)

• To find minimum & maximum element in a list


• NOTE: Use GNU CLISP 2.49 for Windows 7
24
LISP
• Pioneered Functional Programming
– Computations by applying functions to
parameters
– No concept of variables (storage) or assignment
• Single-valued variables: no assignment, no storage
– Control via recursion and conditional expressions
• Branches  conditional expressions
• Iterations  recursion
– Dynamically allocated linked lists

25
First Step Towards Sophistication
• Environment (1957-1958):
– FORTRAN had (barely) arrived for IBM 70x
– Many other languages, but all for specific machines  no
universal language for communicating algorithms
– Programmer productivity became important
• ALGOL: Universal, international, machine-independent
(imperative) language for expressing scientific
algorithms
– ALGOL  ALGOrithm Logic
– Eventually, 3 major designs: ALGOL 58, 60, and 68
– Developed by increasingly large international committees

26
Issues to Address (I)
• Early languages used label-oriented control:
27 ……
… GO TO 27
30 IF (A-B) 5,6,7

• ALGOL supports sufficient phrase-level control,


such as if, while, switch, for, until
structured programming
• Programming style of ALGOL:
– Programs consist of blocks of code: blocks 
functions  files  directories
– Bottom-up development possible
– Easy to develop, read, maintain; make fewer errors
27
Issues to Address (II)
• ALGOL designs avoided special cases:
– Allows Free-format lexical structure
– No arbitrary limits:
• Any number of characters in a name
• Any number of dimensions for an array
– Orthogonality: every meaningful combination of
primitive concepts is legal — no special forbidden
combinations to remember
• Each combination not permitted is a special case that
must be remembered by the programmer

28
Example of Orthogonality

Integers Arrays Procedures


Passing as a parameter ✓ ✓ ✓

Storing in a variable ✓ ✓ ✓

Storing in an array ✓ ✓ ✓

Returning from a procedure ✓ ✓ ✓

• By ALGOL 68, all combinations above are legal


• Modern languages seldom take this principle as
far as ALGOL  expressiveness vs. efficiency
29
Influences
• Virtually all languages after 1958 used ideas
pioneered by the ALGOL designs:
– Free-format lexical structure
– No limit to length of names and array dimension
– BNF definition of syntax
– Concept of type
– Block structure (local scope)
– Compound statement (begin end), nested if-then-else
– Stack - dynamic arrays
– Call by value (or call by name)
– Recursive subroutines and conditional expressions

30
Backus-Naur Form (BNF)

31
COBOL - 1960
• COmmon Business Oriented Language
• First macro facility in a high-level language
• Hierarchical data structures (records)
• Nested selection statements
• Long names (up to 30 characters), with
hyphens

32
Beginning of Timesharing: BASIC
• BASIC (Beginner’s All-purpose Symbolic Instruction
Code)
– John Kemeney and Thomas Kurtz at Dartmouth, 1963
• Design goals:
– Easy to learn and use for non-science students
– Must be “pleasant and friendly”
– Fast turnaround for homework
– Free and private access
– User time is more important than computer time
• First widely used language with time sharing
– Simultaneous individual access through terminals

33
Everything for Everybody  PL/1
• Programming Language One
• IBM at 1963-1964:
– Scientific computing: IBM 1620 and 7090, FORTRAN
– Business computing: IBM 1401 and 7080, COBOL
– Scientific users began to need elaborate I/O, like in COBOL;
business users began to need FP and arrays
• The obvious solution
– New computer to do both  IBM System/360
– Design a new language to do both  PL/I
• Results:
– Unit-level concurrency, first exception handling, pointer
– But, too many and too complex features
34
SNOBOL (1964)
• SNOBOL  “Snow Ball”  StriNg Oriented and
symBOlic Language
• Designed as a string manipulation language
• Designed specifically for text processing.
• Designed at Bell Labs by Farber, Griswold, and
Polensky
• Powerful operators for string pattern matching
• Application: writing text editors
35
Beginning of Data Abstraction
• SIMULA (between 1962 and 1964)
– Designed primarily for System Simulation in University
of Oslo, Norway, by Kristen Nygaard and Ole-Johan Dahl
• Starting 1961: SIMULA I, SIMULA 67
• Primary contributions:
– Co-routines: a kind of subprogram
– Implemented in a structure called a class, which include
both local data and functionality and are the basis for
data abstraction

36
C (1972)
• Designed for systems programming
• Designed at Bell Labs by Dennis Richie
• Evolved primarily from B, but also ALGOL 68
• Powerful set of operators, but poor type
checking
• Initially spread through UNIX

37
Example Program in C
#include<stdio.h>
int main()
{
int balance = 100;
float f = 'a';
printf("%f \n", balance+f);
return 0;
}

38
Object-Oriented Programming
• Smalltalk (1972)
• Initially designed by Alan Kay, later by Adele Goldberg at
Xerox PARC
• First full implementation of an object-oriented language
– Everything is an object: variables, constants, activation
records, classes, etc.
– All computation is performed by objects sending and
receiving messages
– Data abstraction, inheritance, dynamic type binding
• Also pioneered graphical user interface design

39
C++ (1985)
• Developed at Bell Labs by Stroustrup
• Evolved from C and SIMULA 67
• Facilities for object-oriented programming, taken
partially from SIMULA 67, were added to C
• Also has exception handling
• A large and complex language in part, because it
supports both procedural and OO programming
• Rapidly grew in popularity, along with OOP
• ANSI standard approved in November, 1997
40
Java (1995)
• Developed at Sun in the early 1990s
• Based on C++
• Significantly simplified
• Supports only OOP
• Has references, but not pointers
• Includes support for applets and a form of
concurrency

41
Programming Based on Logic:
Prolog
• Developed by Comerauer and Roussel (University of Aix-
Marseille) in 1972, with help from Kowalski (University of
Edinburgh)
• Based on formal logic
• Non-procedural
– Only supply relevant facts (predicate calculus) and inference rules
(resolutions)
– System then infer the truth of given queries/goals
• Can be summarized as being an intelligent database
system that uses an inferencing process to infer the truth
of given queries

42
Logic Languages
• Example: relationship among people
How do you add the following facts?

1. John likes anything that Mary likes


2. John likes anyone who likes wine
3. John likes anyone who likes themselves

Features of logic languages (Prolog):


– Program expressed as rules in formal logic
– Rules are specified in no particular order
– Execution by rule resolution
43
An example: Logic
• Family Tree:

44
Here are the resultant clauses:
-------------------------------
male(james1).
male(charles1).
male(charles2).
male(james2).
male(george1).

female(catherine).
female(elizabeth).
female(sophia).
Here is how you would formulate the following
parent(charles1, james1). queries:
parent(elizabeth, james1).
parent(charles2, charles1). Was George I the parent of Charles I?
parent(catherine, charles1). Query: parent(charles1, george1).
parent(james2, charles1). Who was Charles I's parent?
parent(sophia, elizabeth). Query: parent(charles1,X).
parent(george1, sophia). Who were the children of Charles I?
Query: parent(X,charles1).

Now try expressing the following rules:

mother(M,X) :- parent(M,X), female(M).M is the mother of X if she is a parent of X and is female


F is the father of X if he is a parent of X and is male
X is a sibling of Y if they both have the same parent.
45
Ada - 1983 (began in mid-1970s)
• 1. Packages - support for data abstraction
• 2. Exception handling - elaborate
• 3. Generic program units
• 4. Concurrency - through the tasking model
• NOTE:
– First compilers were very difficult; the first really
usable compiler came nearly five years after the
language design was completed

46
Summary: Application Domain
• Application domains have distinctive (and conflicting)
needs and affect prog. lang.
– Scientific applications: high performance with a large number of
floating point computations, e.g., Fortran
– Business applications: report generation that use decimal
numbers and characters, e.g., COBOL
– Artificial intelligence: symbols rather than numbers manipulated,
e.g., LISP
– Systems programming: low-level access and efficiency for SW
interface to devices, e.g., C
– Web software: diff. kinds of lang. markup (XHTML), scripting
(PHP), general-purpose (Java)
Summary: Programming
Methodology in Perspective
• 1950s and early 1960s: simple applications; worry
about machine efficiency (FORTRAN)
• Late 1960s: people efficiency important; readability,
better control structures (ALGOL)
– Structured programming
– Top-down design and step-wise refinement
• Late 1970s: process-oriented to data-oriented
– Data abstraction
• Middle 1980s: object-oriented programming
– Data abstraction + inheritance + dynamic binding

48
Theory of PL: Turing Equivalence
• Languages have different strengths, but fundamentally
they all have the same power
{problems solvable in Java}
= {problems solvable in Fortran}
=…
• And all have the same power as various mathematical
models of computation
= {problems solvable by Turing machine}
= {problems solvable by lambda calculus}
=…
• Church-Turing thesis: this is what “computability” means

49
Turing Test in Computers
• The Turing test, developed by Alan Turing in 1950
– It is a test of a machine's ability to exhibit intelligent
behavior equivalent to, or indistinguishable from, that
of a human.
• Lambda calculus (also written as λ-calculus)
– It is a formal system in mathematical logic for
expressing computation based on function abstraction
and application using variable binding and
substitution.

50

You might also like