the evolution of programming languages day 3 lecturer: xiao jia [email protected] the evolution of...

Click here to load reader

Post on 01-Jan-2016




0 download

Embed Size (px)


The Evolution of Programming Languages

The Evolution of Programming LanguagesDay 3Lecturer: Xiao [email protected] Evolution of PLs1The Object Oriented ParadigmThe Evolution of PLs2Hoare 1968A fundamental feature of our understanding of the world is that we organize our experience as a number of distinct objectWe often need to construct within the computer a model of that aspect of real or conceptual worldThe Evolution of PLs3SimulaSimula I and Simula 67

Purpose: to model systemsA system is a collection of interacting processesA process can be represented during program execution by multiple procedures each with its own Algol-style stacksThe Evolution of PLs4A Simula Classclass Account (real balance);begin procedure Deposit (real amount) balance := balance + amount; procedure Withdraw (real amount) balance := balance - amount;end;The Evolution of PLs5Use A Simula Classref (Account) myAccount;MyAccount := new Account(1000);

// inherit from AccountAccount class ChequeAccount (real amount);The Evolution of PLs6Featurescoroutines: simulation of concurrent processesmultiple stacks: to support coroutinesclasses: combine data & collection of functionsprefixing: now as known as inheritancegarbage collectionThe Evolution of PLs7Smalltalk1969 (development) 1972 (appear)first implemented using BASICinspired by Simula and LISPThe Evolution of PLs8Six PrinciplesEverything is an objectObjects communicate by sending and receiving messages (in terms of objects)Objects have their own memoryEvery object is an instance of a class (which must be an object)The class holds the shared behavior for its instancesTo evaluate a program list, control is passed to the first object and the remainder is treated as its messageThe Evolution of PLs910 timesRepeat: [Transcript nextPutAll: ' Hi!']

The Evolution of PLs10receiver10 timesRepeat: [Transcript nextPutAll: ' Hi!']

The Evolution of PLs11messageparameter of the messageFirst practical Smalltalk developed in 1976 at Xerox Research Centeran object has private data and public functionsinheritance tree with Object as its rootall classes inherit directly or indirectly from the class Objectblockscoroutinesgarbage collectionThe Evolution of PLs12CLU1974abstract data type (ADT)CLU is designed for programming with ADTsThe Evolution of PLs13Implement a set of integersintset = 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) = 0.0 Result := .... -- square root of x ensure abs(Result * Result / x - 1.0)