Download presentation
Presentation is loading. Please wait.
Published byErica Boyd Modified over 9 years ago
1
The Evolution of Programming Languages Day 3 Lecturer: Xiao Jia xjia@cs.sjtu.edu.cn The Evolution of PLs1
2
The Object Oriented Paradigm The Evolution of PLs2
3
Hoare 1968 A fundamental feature of our understanding of the world is that we organize our experience as a number of distinct object We often need to construct within the computer a model of that aspect of real or conceptual world The Evolution of PLs3
4
Simula Simula I and Simula 67 Purpose: to model systems A system is a collection of interacting processes A process can be represented during program execution by multiple procedures each with its own Algol-style stacks The Evolution of PLs4
5
A Simula Class class Account (real balance); begin procedure Deposit (real amount) balance := balance + amount; procedure Withdraw (real amount) balance := balance - amount; end; The Evolution of PLs5
6
Use A Simula Class ref (Account) myAccount; MyAccount := new Account(1000); // inherit from Account Account class ChequeAccount (real amount); The Evolution of PLs6
7
Features coroutines: simulation of concurrent processes multiple stacks: to support coroutines classes: combine data & collection of functions prefixing: now as known as inheritance garbage collection The Evolution of PLs7
8
Smalltalk 1969 (development) – 1972 (appear) first implemented using BASIC inspired by Simula and LISP The Evolution of PLs8
9
Six Principles 1.Everything is an object 2.Objects communicate by sending and receiving messages (in terms of objects) 3.Objects have their own memory 4.Every object is an instance of a class (which must be an object) 5.The class holds the shared behavior for its instances 6.To evaluate a program list, control is passed to the first object and the remainder is treated as its message The Evolution of PLs9
10
10 timesRepeat: [Transcript nextPutAll: ' Hi!'] The Evolution of PLs10 receiver
11
10 timesRepeat: [Transcript nextPutAll: ' Hi!'] The Evolution of PLs11 message parameter of the message
12
First practical Smalltalk developed in 1976 at Xerox Research Center an object has private data and public functions inheritance tree with Object as its root all classes inherit directly or indirectly from the class Object blocks coroutines garbage collection The Evolution of PLs12
13
CLU 1974 abstract data type (ADT) CLU is designed for programming with ADTs The Evolution of PLs13
14
Implement a set of integers intset = cluster is create, insert, delete, member, size, choose rep = array[int] create = proc () returns (cvt) return (rep$new()) end create insert = proc (s: intset, x: int) if ~member(s, x) then rep$addh(down(s), x) end end insert member = proc (s: cvt, x: int) returns (bool) return (getind(s, x) <= rep$high(s)) end member.... end intset The Evolution of PLs14
15
C++ 1983 superset of C hybrid language emphasize the stack rather than the heap multiple inheritance NO garbage collection The Evolution of PLs15
16
Eiffel Software Engineering was a key objective in the design of Eiffel multiple inheritance strong typing assertions The Evolution of PLs16
17
Eiffel does not have … global variables enumerations subranges goto, break, continue procedure variables casts pointer arithmetic I/O defined by libraries rather than built into the language The Evolution of PLs17
18
Programming by Contract defensive programming sqrt (x: real): real is require x >= 0.0 Result :=.... -- square root of x ensure abs(Result * Result / x - 1.0) <= 1e-6 end The Evolution of PLs18
19
Repeated Inheritance class House feature address: String value: Money end class Residence inherit House rename value as residenceValue end class Business inherit House rename value as businessValue end class HomeBusiness inherit Residence Business.... end The Evolution of PLs19
20
Java 1995 portability security single inheritance interfaces exception handling concurrency: threads garbage collection The Evolution of PLs20
21
Exercise Byte codes provide portability. Can you suggest any other advantages of using byte codes? The Evolution of PLs21
22
Homework Kevo Beta Blue CLOS Self Io The Evolution of PLs22
23
Backtracking Languages (we only talk about Prolog[1972]) The Evolution of PLs23
24
A Family parent(pam, bob). parent(tom, bob). parent(tom, liz). parent(bob, ann). parent(bob, pat). parent(pat, jim). The Evolution of PLs24 Facts
25
Prolog Queries ?- parent(tom, liz). yes ?- parent(tom, jim). no ?- parent(pam, X). X = bob ?- parent(bob, C). C = ann C = pat ?- parent(P, jim), parent(G, P). P = pat G = bob The Evolution of PLs25
26
Adding Rules grandparent(G, C) :- parent(G, P), parent(P, C). sibling(X, Y) :- parent(P, X), parent(P, Y), different(X, Y). ?- sibling(pat, X). X = ann The Evolution of PLs26
27
Recursive Rules ancestor(A, X) :- parent(A, X). ancestor(A, X) :- ancestor(A, P), parent(P, X). ?- ancestor(pam, jim). yes The Evolution of PLs27
28
Cut minimum(X, Y, X) :- X <= Y. minimum(X, Y, Y) :- X > Y. The Evolution of PLs28
29
Cut minimum(X, Y, X) :- X <= Y, !. minimum(X, Y, Y) :- X > Y, !. The Evolution of PLs29
30
Cut different(X, X) :- !, fail. different(X, Y). ?- different(Tom, Tom). no ?- different(Ann, Tom). yes The Evolution of PLs30
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.