1 / 30

The Evolution of Programming Languages

The Evolution of Programming Languages. Day 3 Lecturer: Xiao Jia xjia@cs.sjtu.edu.cn. The Object Oriented Paradigm. Hoare 1968. A fundamental feature of our understanding of the world is that we organize our experience as a number of distinct object

torgny
Download Presentation

The Evolution of Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Evolution of Programming Languages Day 3 Lecturer: Xiao Jia xjia@cs.sjtu.edu.cn The Evolution of PLs

  2. The Object Oriented Paradigm The Evolution of PLs

  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 PLs

  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 PLs

  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 PLs

  6. Use A Simula Class ref (Account) myAccount; MyAccount := new Account(1000); // inherit from Account Account class ChequeAccount (real amount); The Evolution of PLs

  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 PLs

  8. Smalltalk • 1969 (development) – 1972 (appear) • first implemented using BASIC • inspired by Simula and LISP The Evolution of PLs

  9. Six Principles • Everything is an object • Objects communicate by sending and receiving messages (in terms of objects) • Objects have their own memory • Every object is an instance of a class (which must be an object) • The class holds the shared behavior for its instances • To evaluate a program list, control is passed to the first object and the remainder is treated as its message The Evolution of PLs

  10. 10 timesRepeat: [Transcript nextPutAll: ' Hi!'] receiver The Evolution of PLs

  11. 10 timesRepeat: [Transcript nextPutAll: ' Hi!'] message parameter of the message The Evolution of PLs

  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 PLs

  13. CLU • 1974 • abstract data type (ADT) • CLU is designed for programming with ADTs The Evolution of PLs

  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 PLs

  15. C++ • 1983 • superset of C • hybrid language • emphasize the stack rather than the heap • multiple inheritance • NO garbage collection The Evolution of PLs

  16. Eiffel • Software Engineering was a key objective in the design of Eiffel • multiple inheritance • strong typing • assertions The Evolution of PLs

  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 PLs

  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 PLs

  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 PLs

  20. Java • 1995 • portability • security • single inheritance • interfaces • exception handling • concurrency: threads • garbage collection The Evolution of PLs

  21. Exercise • Byte codes provide portability. • Can you suggest any other advantages of using byte codes? The Evolution of PLs

  22. Homework • Kevo • Beta • Blue • CLOS • Self • Io The Evolution of PLs

  23. Backtracking Languages (we only talk about Prolog[1972]) The Evolution of PLs

  24. A Family parent(pam, bob). parent(tom, bob). parent(tom, liz). parent(bob, ann). parent(bob, pat). parent(pat, jim). Facts The Evolution of PLs

  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 PLs

  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 PLs

  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 PLs

  28. Cut minimum(X, Y, X) :- X <= Y. minimum(X, Y, Y) :- X > Y. The Evolution of PLs

  29. Cut minimum(X, Y, X) :- X <= Y, !. minimum(X, Y, Y) :- X > Y, !. The Evolution of PLs

  30. Cut different(X, X) :- !, fail. different(X, Y). ?- different(Tom, Tom). no ?- different(Ann, Tom). yes The Evolution of PLs

More Related