XXXXXXXXXXXXXXXXXXXXXXX. Evolution of Software Languages

Size: px
Start display at page:

Download "XXXXXXXXXXXXXXXXXXXXXXX. Evolution of Software Languages"

Transcription

1 Section 8: Simula Smalltalk Evolution of Software Languages Theo D'Hondt Bachelor of Computer Science Faculty of Sciences and Bio-Engineering Sciences Vrije Universiteit Brussel Academic Year

2 Ole-Johan Dahl Kristen Nygaard Simulation language Simula I Simula 67 Extension of Algol 60 Call-by-value default Call-by-name still around Hoare s Record Classes 2

3 Simula basics Class class C(... ); begin... end; Prefix class A class B; begin... end; Garbage collection Assignment begin x := y; p :- q; end; Nested classes class A; begin class B; begin... end; B class C; begin... end;... end; Prefix blocks A begin... B... end; Class parameters class C(... )... new C(...) Casts a qua B.c The development of the SIMULA languages Kristen Nygaard, Ole-Johan Dahl HISTORY OF PROGRAMMING LANGUAGES 439, 1981 ACM ISBN No multiple inheritance X, Y class Z(... ); begin... end; Dot notation C.v Procedures setter :- boolean procedure (... ) begin... end; Virtual entities virtual procedure V(... ) begin... end; 3

4 Hoare s Record Classes cord Classes in 1966 ariation in data structures Expression Constant value: real Variable name: string BinaryExpr left: reference(expression) right: reference(expression) ession) left, right; nce, Product, Quotient)); Sum Product Difference Quotient Subclassing through concatenation 4

5 Simula example: overriding begin class Vehicle; virtual: procedure sound is procedure sound;; begin end; Vehicle class Car ; begin procedure sound; begin OutText("Beep beep"); OutImage; end; end; taken from: /2014-fall/slides/25-history-oo.pdf Vehicle class Bike; begin procedure sound; begin OutText("Ding ding"); OutImage; end; end; ref (Vehicle) array vehicles (1 : 2); Integer i; vehicles (1) :- new Car; vehicles (2) :- new Bike; for i := 1 step 1 until 2 do vehicles(i).sound end; 5

6 Simula example: simulation begin ref (Car) acar; ref (Truck) atruck; class Car; begin Integer N; detach; for N := 1 step 1 until 10 do begin OutText("Driving me insane"); OutImage; resume(atruck); end; end; taken from: /2014-fall/slides/25-history-oo.pdf class Truck; begin Integer N; detach; for N := 1 step 1 until 10 do begin OutText("Keep on truckin'"); OutImage; resume(acar); end; end; acar :- new Car; atruck :- new Truck; resume(acar); end; 6

7 Alan Kay: Xerox PARC computer-history/ /appleand-xerox-parc 7

8 Smalltalk 80 Requires a workstation 1Mpixels memory-mapped display 1Mb memory 32bits processor pointing device with 2 buttons Uses a virtual machine with bytecodes Uses a garbage collecting memory manager Uses a uniform memory model (image) Uses an integrated graphical kernel Uses an object model for all language concepts Single inhertance, ad-hoc poymorphism Uses strong and dynamic typing of all values Metaprogramming and computational reflection A true IDE 8

9 Smalltalk-80 XXXXXXXXXXXXXXXXXXXXXXX the Blue Book 9

10 VUB 10

11 Terminology1 Object Message Receiver Element of Smalltalk composed of private datastructures and a set of operations. Request for an object to perform one of its operations. Object that receives a message. Interface Set of messages identified by an object. Class Instance Specification of the set of objects with identical behaviour Representative of a Class 11

12 Terminology1 Object Message Receiver Interface Element of Smalltalk composed of private datastructures and a set of operations. Request for an object to perform one of its operations. Object that receives a message. Set of messages identified by an object. Class Specification of the set of objects with identical behaviour Representative of a Class InstanceEverything is an object 12

13 Terminology2 Instance variable Method Primitive method System class Name of a private datastructure of an object Implementation of an operation of an object Method directly executed by the Smalltalk virtual machine. Class of the Smalltalk virtual image 13

14 Literal objects Numerical Character String Symbol Aggregate literal objects #('January' ) #(( one' 1 $1) ('two' 2 $2)... ( zero' 0 $0)) 14

15 Variables Variable name Private variables Shared variables Letters, digits Lower case initial Upper case initial 15

16 Pseudo variables Names that refer to specific objects Cannot be assigned a value with <- Some are constant Some have a value depending on the context nil true, false self, super Undefined variable Boolean values Reference to receiver Boolean object = object with interface all messages for logical operations 16

17 Temporary variables argument names and self only exist during the method activation moreover one can introduce local variables with the same characteristics these are being enumerated nominatively between message - pattern and method, preceded and followed by $ ; these are initialized to nil 17

18 Assignment name1 <- name2 <-... <- namen <- expression binds structure as well as contents to a name name refers to an instance of the class determined by the expression colour <- #('red' 'orange' 'green') 18

19 Messages = interactions between objects <receiver> <selector> [ <arguments> ] <receiver> <selector> <arguments> = object that receives and implements the = identity of the message = additional expressions that play a role in the method that implements the message 19

20 Message patterns operator message one or two non alpha numerical symbols ( last $ ); there is exactly one argument numerator / denominator unary message alpha-numerical name and no arguments discriminant sqrt keyword message one or more alpha-numerical names each followed by $:; each keyword associated with an argument letter from:'donald' on:#( ) 20

21 Message evaluation The result of the evaluation of a method, consequence of the sending of a corresponding message, is an object Messages are bi-directional sum < binds the integer object implementing 3 to sum The object returned by a method is not necessarily used Messages are 2nd class function calls 21

22 Left to right for unary messages and operators Unary messages have precedence D <- (b * b (4 * a * c)) sqrt Parentheses are used for reversal of this rule perimeter <- ((rectangle width) + (rectangle height)) * 2 22

23 Expression evaluation2 in case of non unary messages complex arguments have to be enclosed in parentheses R width: x height y R width: (x height y) operators have priority over non unary messages rectangle width: x * 2 height: y * 4 23

24 Cascading multiple successive messages to one object turtle FD: 10; RT: 90; BK: 5 24

25 Blocks Expression of one or more sequential interactions enclosed by $[ and $] and separated by $. Blocks can be assigned to variables : move <- [ turtle FD: 10. turtle RT: 90. turtle BK: 5 ] Does not imply the execution Execution occurs after sending the message value move value 25

26 Control structures1 iteration <integer> timesrepeat: <block> 4 timesrepeat [turtle FD: 50; RT: 90] selection <boolean expression> iftrue: <block> iffalse: <block> x < a > b iftrue:[ a ] iffalse: [ b ] 26

27 Control structures2 block arguments = variable names with $: prefix appearing at the beginning of the block, terminated by $ [:count :sum [count < 10] whiletrue: [count < count + 1. sum < sum + array at: tel]. sum < sum / count ] value: #(0 0) i < 1. [i <= 10] whiletrue: [sum < sum + (list at: i). i < i + 1] 27

28 Control structures2 block arguments = variable names with $: prefix appearing at the beginning of the block, terminated by $ [:count :sum [count < 10] whiletrue: [count < count + 1. sum < sum + array at: tel]. sum < sum / count ] value: #(0 0) closures i < 1. [i <= 10] whiletrue: [sum < sum + (list at: i). i < i + 1] 28

29 Applicative operations do: -message sum < 0. #( ) do: [:sq sum < sum + (sq * sq)] collect: -message list < #( ) collect: [:sq sq * sq] 29

30 Classes Objects For all elements in Smalltalk ( from constant to entire compiler ) Interaction by way of messages that make functionality of the object available. The implementation is hidden Each object is an instance of a class All objects of a class have the same interface 30

31 Classes1 { instance variables } U { methods } Identified by a shared variable - An object identifies its class - Classes are manipulated within an expression A class is an object an instance of a class is created by sending it a message rt < Rectangle new Some classes accept additional messages now < Date today 31

32 Protocol a class is implemented in 2 stages defines # and structure of accepted messages says what, not how is composed of message patterns <message selector> <arguments> selector to be used when sending the message symbolic name(s) for the argument 32

33 Message pattern message rt < Rectangle new. rt lowerleft: # (0 0) upperright: # (10 20) message pattern lowerleft: lb upperright: ra a message pattern is compared ( " matched " ) to a message when sent, and expressions are bound to the symbolic names 33

34 Message implementation A method implements a message argument names refer to expressions within the message, expressions are evaluated one by one; read - only The return - value is stated in one of these two ways : ( 1 ) implicit, the receiver ( 2 ) explicit with arithmetic expressions, i.e. expression with prefix $^ 34

35 Variables a method has access to ( 1 ) instance ( 2 ) temporal ( 3 ) class ( 4 ) global ( 5 ) " pool " name of the class instance variables methods remark : ±free syntax differentiation by way of fonts 35

36 Instance variables lower case initial exist for the total life time of the object are only visible for the implementation of the object represent the state of the object 36

37 Temporary variables lower case initial ) only exist during the execution of a method are only visible for this method are being created / destroyed with sending of message 37

38 Class variables upper case initial identify each of the classes present ( mostly shared variables ) visible everywhere 38

39 Global variables upper case initial instance of an object, beginning with upper case letter visible everywhere 39

40 Pool variables upper case initial shared " variable with limited visibility common to every instance of a subset of the { all classes } 40

41 Primitive methods most methods are implemented by sending messages to other objects some are directly interpreted by Smalltalk : the primitive methods there are more or less a 100 " standard " primitive methods 41

42 Named instance variables added to the list of instance variables are referenced in message expressions making up the methods default initialisation "nil" 42

43 Indexed instance variables1 added to the list implicitly there is only one indexed instance per object are indexed with the at: and at:put: messages indexed with numbers from [ 1, [ 2 instances have = named i.v. but not necessary = # indexed i.v. 43

44 Indexed instance variables2 For instance in String: at: index put: value (size < index ) iftrue: [ self error "overflow"] iffalse: [ ^ self at: index put: value ] at: index ( size < index ) iftrue: [ ^ nil ] iffalse: [ ^ self at: index ] 44

45 Indexed instance variables3 indexed classes ( = classes with indexed instance variables) being instantiated with new: max if at: and at: put: are defined as messages upon an indexed class, then aggregates can be assigned 45

46 Self reference via the self pseudo variable. self refers to the receiver of the message that is being executed. factorial (self = 0) iftrue: [ ^ 1 ]. (self < 0) iftrue: [ self wrong: 'wrong' ] iffalse: [ ^ self * (self - 1) factorial ] 46

47 Subclasses is derived from an existing class the instance variables are automatically copied the list of instance variables may be extended the methods, if not "overridden" are being copied " overriding" happens by introducing a homonym at the subclass level 47

48 Class names class-names are unique instance variable names are unique within a class definition method-names ( message pattern) are unique within a class definition unique within a range of superclasses 48

49 Superclasses a superclass of a class K = a class which K is a subclass of normally : for each class K there is one superclass for each class K there are 0 or more subclasses this defines an hierarchical structure at the root of which we find a unique class that has no superclass: Object 49

50 Superclass chain consider a class K the series of classes, beginning at Object and ending at K such that any 2 succesive classes are each other's superclass / subclass is the superclass chain of K if a message M with pattern P is sent to an instance I of K, the first method encountered with pattern P in the superclass chain of K is executed 50

51 Method lookup (1) M - pattern in K ---> corresponding method is executed (2) M - pattern not in K ---> (a) K = Object ---> abort (b) K <> Object ---> substitute super (K) for K and ---> (1) 51

52 ZZZ self refers to M's receiver ( = instance I of K ) M's method lookup starts in K if delegation ---> superclass this remains the case super = to self M's method lookup starts with the superclass of the class containing the method that contains the message 52

53 Abstract superclasses only serve to be transformed in subclasses should "never" be instantiated 53

54 Subclass framework subclassresponsibility standard message in Object self subclassresponsability generates an errormessage, and is used as implementation of a message in an abstract subclass, which should be overridden in a subclass shouldnotimplement standard message in Object self shouldnotimplement generates an errormessage and is used as implementation of a method that is impossible to implement. 54

55 Metaclasses1 classes are objects ---> each class is instance of a class, called metaclass Object is superclass of each class 55

56 Metaclasses2 the class CLASS is: an abstract superclass of all metaclasses subclass of Object a class and its (meta)class are defined together distinction is made between " class methods " and "instance methods " used for for class instantiation 56

57 Metaclasses3 metaclasses inherit from superclasses with a restriction: there is a parallellism in sub / superclasses between metaclasses and classes IF : class c1 instance of metaclass m1 class c2 instance of metaclass m2 THEN : c1 subclass of c2 m1 subclass of m2 57

58 Object interface1 functionality: class iskindof: aclass ismemberof: aclass ---> receiver's class ---> true if aclass = receiver's class ---> true if aclass (super*) = receiver's class respondsto: asymbol ---> true if asymbol element is of the interface of the receiver's class 58

59 59 XXXXXXXXXXXXXXXXXXXXXXX Object interface2 comparison: == anobject = anobject ~ = anobject ~~ = anobject hash ---> true if receiver and anobject = ---> true if receiver and anobject refer to the same components ---> true if receiver and anobject are not = ---> true if receiver and anobject are not == ---> unique integer reference of the receiver

60 Object interface3 copy : copy shallowcopy ---> instance with equal instance-variable content or shared variable ---> instance with shared instance variables deepcopy ---> instance with copy of the instance variables 60

61 Object interface4 access: at : index at : index put : anobject basicat : index basicat : index put : anobject size basicsize 61

62 Object interface5 error handling: doesnotunderstand: amessage states that the receiver does not understand "amessage" error : astring statement of error identified by "astring" to receiver primitivefailed statement that systemprimitive is abused by receiver shouldnotimplement see before subclassresponsability 62

63 Dictionary framework1 Object subclass: #AbstractDictionary instancevariablenames: 'names values' classvariablenames: '' pooldictionaries: '' category: 'DemoDictionaries' class methods instantiation new private "instantiate new dictionary" size size := self minimalsize. ^ (super new ) initialize: size minimalsize "implementation dependent initial size" self subclassresponsibility instance methods statistics size "dictionary size" self subclassresponsibility 63

64 Dictionary framework2 access at: key "retrieve value corresponding to key" ^self at: key notfound: [ self error: 'key not found'] at: key notfound: block "retrieve value corresponding to key, with user error handling" index index := self indexatkey: key. (index = 0) iftrue: [ block value ] iffalse: [ ^values at: index ] at: key put: value "insert new key / value pair" self at: key put: value duplicate: [ self error: 'duplicate key' ] 64

65 Dictionary framework3 at: key put: value duplicate: block "insert new key / value pair with user error handling" index index <- self newindexatkey: key. (index = 0) iftrue: [ block value ] iffalse: [ values at: index put: value ] at: key replace: value "replace value in existing pair" self at: key replace: value notfound: [self error: 'key not found' ] at: key replace: value notfound: block "replace value in existing pair with user error handling" index index := self indexatkey: key. (index = 0) iftrue: [ block value ] iffalse: [ values at: index put: value ] 65

66 Dictionary framework4 newindexatkey: key "locate index for new key in names" (( self indexatkey: key) = 0) iftrue: [ self extend. names at: names size put: key. ^ names size ] iffalse: [ ^ 0 ] extend "extend implementation by one pair" oldnames oldvalues newsize oldnames := names. oldvalues := values. newsize := names size + 1. names := Array new: newsize. values := Array new: newsize. (1 to: oldnames size) do: [ :index names at: index put: ( oldnames at: index ). values at: index put: ( oldvalues at: index ) ] 66

67 Dictionary framework5 AbstractDictionary subclass: #FastDictionary instancevariablenames: 'size ' classvariablenames: '' pooldictionaries: '' category: 'DemoDictionaries' class methods instantiation new "instantiate new fast dictionary" ^ (super new ) initializesize private minimalsize "implementation dependent initial size" ^4 instance methods statistics size private "dictionary size" ^size 67

68 Dictionary framework6 indexatkey: key "locate index of key in names" index index := ( key hash \\ names size ) + 1. [ ( names at: index ) = key ] whilefalse: [ (names at: index) isnil iftrue: [ ^ 0 ]. index := ( index \\ names size ) + 1 ]. ^ index newindexatkey: key "locate index for new key in names" index (size = names size) iftrue: [ self extend ]. index := ( key hash \\ names size ) + 1. [ ( names at: index ) = key ] whilefalse: [ (names at: index) isnil iftrue: [ size := size + 1. names at: index put: key. ^ index ]. index := ( index \\ names size ) + 1 ]. ^ 0 68

69 Dictionary framework7 extend "extend implementation by doubling the number of pairs" oldnames oldvalues newsize oldnames := names. oldvalues := values. newsize := names size * 2. names := Array new: newsize. values := Array new: newsize. size := 0. (1 to: oldnames size) do: [ :index self at: ( oldnames at: index ) put: ( oldvalues at: index ) ] initializesize "set initial size to 0" size := 0 69

70 Conduit framework1 join pipe source pipe sink source 7 70

71 Conduit framework1 Object subclass: #Conduit instancevariablenames: 'name time capacity content ' classvariablenames: 'ConduitCollection ' pooldictionaries: '' category: 'Conduit-simulation' instance methods private name: aname capacity: acapacity "initialize a new Conduit" time := 0. content := 0. name := aname. capacity := acapacity. self report: 'capacity:' with: capacity 71

72 Conduit framework1 Object subclass: #Conduit instancevariablenames: 'name time capacity content ' classvariablenames: 'ConduitCollection ' pooldictionaries: '' reporting category: 'Conduit-simulation' instance methods private Transcript show: name; tab. name: aname capacity: acapacity Transcript show: 'error:'; tab. "initialize a new Conduit" Transcript show: amessage; cr. time := 0. self halt content := 0. name := aname. capacity := acapacity. self report: 'capacity:' with: capacity error: amessage "report error message" Transcript show: 't ='; tab. Transcript show: time printstring; tab. report: amessage with: anumber "report status message" Transcript show: 't ='; tab. Transcript show: time printstring; tab. Transcript show: name; tab. Transcript show: amessage; tab. Transcript show: anumber printstring; cr 72

73 Conduit framework1 Object subclass: #Conduit instancevariablenames: 'name processing time capacity content ' classvariablenames: 'ConduitCollection ' pooldictionaries: '' reporting fill category: 'Conduit-simulation' "instruct the conduit to fill itself" error: amessage self subclassresponsibility instance methods "report error message" process Transcript show: 't ='; tab. private Transcript "instruct show: the conduit time printstring; to process itself" tab. Transcript ^ self fill show: name; tab. name: aname capacity: acapacity Transcript show: 'error:'; tab. "initialize a new Conduit" tick Transcript show: amessage; cr. time := 0. self "try halt to advance the clock" content := 0. flow name := aname. report: flow amessage := self process. with: anumber capacity := acapacity. "report flow isnil status message" self report: 'capacity:' with: capacity Transcript iffalse: show: 't ='; tab. Transcript [ content show: := time content printstring; + flow. tab. Transcript time show: := time name; + 1. tab. Transcript self show: report: amessage; 'filled' with: tab. flow. Transcript self show: report: anumber 'contains' printstring; with: content cr ] 73

74 Conduit class framework1 methods name: aname capacity: acapacity Object subclass: #Conduit "instantiate a new Conduit" instancevariablenames: 'name processing time conduit capacity content ' classvariablenames: 'ConduitCollection conduit ':= super new name: aname capacity: acapacity. pooldictionaries: '' reporting fill ConduitCollection add: conduit. category: 'Conduit-simulation' "instruct ^ conduit the conduit to fill itself" error: amessage self subclassresponsibility instance methods new "report error message" process Transcript "disable show: message 't ='; " tab. private Transcript "instruct self shouldnotimplement show: the conduit time printstring; to process itself" tab. Transcript ^ self fill show: name; tab. name: aname capacity: acapacity simulation Transcript show: 'error:'; tab. "initialize a new Conduit" tick Transcript show: amessage; cr. time := 0. run: self "try acount halt to advance the clock" content := 0. "perform flow simulation" name := aname. report: flow amessage acount := self timesrepeat: process. with: anumber capacity := acapacity. "report flow isnil status [ ConduitCollection message" do: [ : conduit conduit tick] ] self report: 'capacity:' with: capacity Transcript iffalse: show: 't ='; tab. initialisation Transcript [ content show: := time content printstring; + flow. tab. Transcript time show: := time name; + 1. tab. initialize Transcript self show: report: amessage; 'filled' with: tab. flow. Transcript "initialise self show: report: Conduit anumber 'contains' framework" printstring; with: content cr ] Transcript clear; show: 'Conduit simulation'; cr. ConduitCollection := OrderedCollection new instance creation 74

75 Conduit class framework1 methods name: aname capacity: acapacity Object subclass: #Conduit "instantiate a new Conduit" example instancevariablenames: 'name processing time conduit capacity content ' classvariablenames: 'ConduitCollection conduit ':= super new name: aname capacity: acapacity. simulate pooldictionaries: '' reporting fill ConduitCollection add: conduit. "Conduit category: simulate" 'Conduit-simulation' "instruct ^ conduit the conduit to fill itself" source1 source2 pipe1 pipe2 pipe3 error: join1 amessage self sink1 subclassresponsibility Conduit instance initialize. methods new "report error message" source1 := Source name: 'Source 1' process capacity: Transcript "disable 5 profile: show: message 't#((10 ='; " tab. 1) (20 3) (40 1) (50 4) (80 1) (90 5)). pipe1 private := Pipe name: 'Pipe 1' capacity: Transcript 4 "instruct inconduit: self shouldnotimplement show: the source1. conduit time printstring; to process itself" tab. source2 := Source name: 'Source 2' capacity: Transcript ^ self fill 4 profile: show: name; #((10 2) tab. (20 4) (40 1) (50 2) (80 1) (90 4)). pipe2 name: := Pipe aname name: capacity: 'Pipe 2' capacity: acapacity simulation Transcript 2 inconduit: show: source2. 'error:'; tab. join1 := "initialize Join name: a new 'Join Conduit" 1' capacity: tick Transcript 3 inconduit1: show: pipe1 amessage; inconduit2: cr. pipe2. pipe3 := time Pipe := name: 0. 'Pipe 3' capacity: run: self 3 "try inconduit: acount halt to advance join1. the clock" sink1 := content Sink name: := 0. 'Sink 1' capacity: 4 "perform inconduit: flow simulation" pipe3. Conduit name run: 50 := aname. report: flow amessage acount := self timesrepeat: process. with: anumber capacity := acapacity. "report flow isnil status [ ConduitCollection message" do: [ : conduit conduit tick] ] self report: 'capacity:' with: capacity Transcript iffalse: show: 't ='; tab. initialisation Transcript [ content show: := time content printstring; + flow. tab. Transcript time show: := time name; + 1. tab. initialize Transcript self show: report: amessage; 'filled' with: tab. flow. Transcript "initialise self show: report: Conduit anumber 'contains' framework" printstring; with: content cr ] Transcript clear; show: 'Conduit simulation'; cr. ConduitCollection := OrderedCollection new instance creation 75

76 Conduit framework1 Conduit subclass: #Sink instancevariablenames: 'inconduit ' classvariablenames: '' pooldictionaries: '' category: 'Conduit-simulation' instance methods processing fill fill "instruct the Sink to fill itself" ^ inconduit drain: capacity capacity ~ section private inconduit: adrainableconduit "initialize a new Sink" inconduit := adrainableconduit class methods instance creation name: aname capacity: acapacity inconduit: adrainableconduit "instantiate a new Source" ^ (super name: aname capacity: acapacity) inconduit: adrainableconduit 76

77 Conduit framework1 Conduit subclass: #DrainableConduit instancevariablenames: 'lastflow ' classvariablenames: '' pooldictionaries: '' category: 'Conduit-simulation' instance methods processing drain: maxflow "drain the Conduit" flow lastflow isnil iffalse: [ lastflow := nil. flow := self flush: maxflow. content := content - flow. self report: 'drained' with: flow. ^flow ] iftrue: [ self report: 'requested' with: maxflow. ^ nil ] 77

78 Conduit framework1 Conduit subclass: #DrainableConduit instancevariablenames: 'lastflow ' classvariablenames: '' pooldictionaries: '' category: 'Conduit-simulation' instance methods processing flush: maxflow "flush the Conduit" content > maxflow iftrue: [ ^ maxflow ] iffalse: [ ^ content ] flow := self flush: maxflow. content := content process - flow. self report: 'drained' with: "instruct flow. the conduit to process itself" lastflow isnil iftrue: [ self report: 'requested' with: maxflow. [ lastflow := self fill ]. ^ nil ] ^ lastflow drain: maxflow "drain the Conduit" flow lastflow isnil iffalse: [ lastflow := nil. ^flow ] iftrue: 78

79 Conduit framework1 DrainableConduit subclass: #Pipe instancevariablenames: 'inconduit cells ' classvariablenames: 'PipeLength ' pooldictionaries: '' category: 'Conduit-simulation' instance methods private inconduit: adrainableconduit "specific initialisation" PipeLength isnil iftrue: [ PipeLength := 10 ]. inconduit := adrainableconduit. cells := (Array new: PipeLength) atallput: 0 delay ~ length fill drain capacity ~ section 79

80 Conduit framework1 DrainableConduit subclass: #Pipe instancevariablenames: 'inconduit processing cells ' classvariablenames: 'PipeLength ' pooldictionaries: '' fill category: 'Conduit-simulation' "instruct the Pipe to fill itself" instance methods private inconduit: adrainableconduit "specific initialisation" PipeLength isnil iftrue: [ PipeLength := 10 ]. inconduit := adrainableconduit. cells := (Array new: PipeLength) atallput: 0 flow free used available used := cells at: 1. flow := inconduit drain: capacity - used. flow isnil iftrue: [ ^ nil ]. cells at: 1 put: used + flow. PipeLength to: 2 by: -1 do: [ : index available := cells at: index - 1. used := cells at: index. free := capacity - used. available <= free iftrue: [ cells at: index - 1 put: 0. cells at: index put: used + available ] iffalse: [ cells at: index - 1 put: available - free. cells at: index put: capacity ] ]. ^ flow 80

81 Conduit framework1 DrainableConduit subclass: #Pipe instancevariablenames: 'inconduit processing cells ' classvariablenames: 'PipeLength ' pooldictionaries: '' fill category: 'Conduit-simulation' "instruct the Pipe to fill itself" flow free used available instance methods used := cells at: 1. flush: maxflow flow := inconduit drain: capacity - used. private "flush the Pipe" flow isnil available iftrue: inconduit: adrainableconduit available := cells at: PipeLength. [ ^ nil ]. "specific initialisation" available > maxflow cells at: 1 put: used + flow. PipeLength isnil iftrue: PipeLength to: 2 by: -1 do: iftrue: [ cells at: [ PipeLength : index put: (available - maxflow). [ PipeLength := 10 ^ ]. maxflow available ] := cells at: index - 1. inconduit := adrainableconduit. iffalse: used := cells at: index. cells := (Array new: PipeLength) [ cells at: atallput: PipeLength free := 0 capacity put: 0. - used. ^ available available ] <= free iftrue: [ cells at: index - 1 put: 0. cells at: index put: used + available ] iffalse: [ cells at: index - 1 put: available - free. cells at: index put: capacity ] ]. ^ flow 81

82 Conduit framework1 DrainableConduit subclass: #Pipe instancevariablenames: 'inconduit processing cells ' classvariablenames: 'PipeLength ' pooldictionaries: '' fill category: 'Conduit-simulation' "instruct the Pipe to fill itself" flow free used available instance methods used := cells at: 1. flush: maxflow flow := inconduit drain: capacity - used. private "flush the Pipe" flow isnil available iftrue: inconduit: adrainableconduit available := cells at: PipeLength. [ ^ nil ]. "specific initialisation" available > maxflow cells at: 1 put: used + flow. PipeLength isnil iftrue: PipeLength to: 2 by: -1 do: iftrue: [ cells at: [ PipeLength : index put: (available - maxflow). class methods [ PipeLength := 10 ^ ]. maxflow available ] := cells at: index - 1. inconduit := adrainableconduit. iffalse: used := cells at: index. instance creation cells := (Array new: PipeLength) [ cells at: atallput: PipeLength free := 0 capacity put: 0. - used. ^ available available ] <= free name: aname capacity: acapacity inconduit: adrainableconduit iftrue: "instantiate a new Pipe" [ cells at: index - 1 put: 0. ^(super name: aname capacity: acapacity) inconduit: cells adrainableconduit at: index put: used + available ] iffalse: [ cells at: index - 1 put: available - free. cells at: index put: capacity ] ]. ^ flow 82

83 Conduit framework1 DrainableConduit subclass: #Join instancevariablenames: 'inconduit1 inconduit2 flow1 flow2 ' classvariablenames: '' pooldictionaries: '' category: 'Conduit-simulation' delay ~ standard instance methods processing fill fill fill "instruct the Join to fill itself" flow flow1 isnil iftrue: [ flow1 := inconduit1 drain: (capacity - content) // 2 ]. flow2 isnil iftrue: [ flow2 := inconduit2 drain: (capacity - content + 1) // 2 ]. flow1 isnil flow2 isnil iftrue: [ ^ nil ] iffalse: [ flow := flow1 + flow2. flow1 := nil. flow2 := nil. ^ flow ] 83 capacity ~ section drain

84 Conduit framework1 DrainableConduit subclass: #Join processing instancevariablenames: 'inconduit1 inconduit2 flow1 flow2 ' classvariablenames: '' fill pooldictionaries: '' "instruct the Pipe to fill itself" category: 'Conduit-simulation' flow free used available used := cells at: 1. instance methods flow := inconduit drain: capacity - used. flow isnil processing iftrue: [ ^ nil ]. fill private cells at: 1 put: used + flow. "instruct the Join to fill itself" PipeLength to: 2 by: -1 do: flow inconduit1: adrainableconduit1 [ : index inconduit2: adrainableconduit2 flow1 isnil iftrue: "initialize a new Join" available := cells at: index - 1. [ flow1 := drain: (capacity - content) used := cells // 2 at: ]. index. class methods inconduit1 := adrainableconduit1. flow2 isnil iftrue: inconduit2 := adrainableconduit2. free := capacity - used. [ flow2 := inconduit2 drain: (capacity - content available + <= 1) // free instance creation flow1 := nil. 2 ]. flow1 isnil flow2 flow2 isnil := nil iftrue: iftrue: [ cells at: index - 1 put: 0. name: aname capacity: acapacity inconduit1: adrainableconduit1 [ ^ nil ] cells at: index put: used + available ] inconduit2: iffalse: iffalse: adrainableconduit2 "instantiate a new Join" [ flow := flow1 + flow2. [ cells at: index - 1 put: available - free. ^ (super name: aname capacity: acapacity) flow1 := nil. cells at: index put: capacity ] ]. inconduit1: adrainableconduit1 flow2 := nil. ^ flow inconduit2: adrainableconduit2 ^ flow ] 84

85 Conduit framework1 DrainableConduit subclass: #Source instancevariablenames: 'sourceprofile produced ' classvariablenames: '' pooldictionaries: '' category: 'Conduit-simulation' fill instance methods capacity ~ volume processing fill "instruct the Source to fill itself" flow flow := sourceprofile check: time. (content + flow) > capacity iftrue: [ self report: 'overflow' with: content + flow - capacity. flow := capacity - content ]. produced := produced + flow. self report: 'produced' with: produced. ^ flow drain 85

86 Conduit framework1 private DrainableConduit subclass: #Source profile: asequence instancevariablenames: 'sourceprofile produced ' "specific initialisation" classvariablenames: '' item pooldictionaries: '' produced := 0. category: 'Conduit-simulation' sourceprofile := Profile new. 1 to: asequence size do: instance methods [ : index item := asequence at: index. processing sourceprofile register: (item at: 1) with: (item at: 2) ] fill "instruct the Source to fill itself" flow flow := sourceprofile check: time. (content + flow) > capacity iftrue: [ self report: 'overflow' with: content + flow - capacity. flow := capacity - content ]. produced := produced + flow. self report: 'produced' with: produced. ^ flow 86

87 Conduit framework1 private DrainableConduit subclass: #Source profile: asequence instancevariablenames: 'sourceprofile produced ' "specific initialisation" classvariablenames: '' item pooldictionaries: '' produced := 0. category: 'Conduit-simulation' sourceprofile := Profile new. 1 to: asequence size do: instance methods [ : index item := asequence at: index. processing sourceprofile register: (item at: 1) with: (item at: 2) ] class methods fill "instruct instance the Source creation to fill itself" flow flow := sourceprofile name: aname check: capacity: time. acapacity profile: asequence (content + flow) "instantiate > capacity a new Source" iftrue: ^ (super name: aname capacity: acapacity) profile: asequence Conduit initialize [ self report: 'overflow' with: content + flow - capacity. flow := capacity - content ]. produced := produced + flow. self report: 'produced' with: produced. ^ flow 87

88 Conduit framework1 configuration Object subclass: #Profile instancevariablenames: 'times flows register: top ' atime with: aflow classvariablenames: 'MaxTable MaxTime "set ' times and flows" pooldictionaries: '' top = MaxTable category: 'Conduit-simulation' iftrue: [ self error: 'Profile overflow' ]. instance methods top := top + 1. times at: top put: atime. accessing flows at: top put: aflow 4 check: atime "retrieve current flow" time top = 0 iftrue: private initprofile "initialize a new Profile" MaxTable isnil [ self error: 'Profile not initialized' ]. iftrue: time := atime rem: MaxTime. [ MaxTable := to: top do: [ :index class methods MaxTime := 100 ]. top := 0. (times at: index) >= time iftrue: instance creation times := Array new: MaxTable. flows := Array new: MaxTable [ ^ flows at: index ] ]. ^ flows at: 1 new "instantiate a new Profile " ^ super new initprofile

89 Smalltalk goodies Memory management with handles (become:) Garbage collection Integrated graphics (bitblt) Metaprogramming Processes Model view controller Collections... 89

90 Smalltalk goodies Memory management with handles (become:) Garbage collection Integrated graphics (bitblt) Metaprogramming BUT... Processes No vararg (perform:) Model view controller Closures methods Collections Single image

91 Conclusion Smalltalk is major milestone: less powerful than Lisp but much more accessible It made objects popular It made dynamic languages popular It made metaprogramming popular It made garbage collection popular It showed the way for GUI / IDE It enabled versioning and OO databases It led the way to Self, Java,... It was/is a commercially viable platform And so many things more... 91

92 Assignment 1. Make Squeak run ( 2. Make Squeak run the Conduit simulation 92

Squeak Object Model. Technion - Israel Institute of Technology. Updated: Spring Object-Oriented Programming 1

Squeak Object Model. Technion - Israel Institute of Technology. Updated: Spring Object-Oriented Programming 1 Squeak Object Model Technion - Israel Institute of Technology Updated: Spring 2015 236703 - Object-Oriented Programming 1 Agenda Class exploring Class object, default / common behaviors Objects equality

More information

Pharo Syntax in a Nutshell

Pharo Syntax in a Nutshell Pharo Syntax in a Nutshell Damien Cassou, Stéphane Ducasse and Luc Fabresse W1S06, 2015 W1S06 2 / 28 Getting a Feel About Syntax In this lecture we want to give you the general feel to get started: Overview

More information

The Smalltalk class hierarchy

The Smalltalk class hierarchy The Smalltalk class hierarchy As we have seen, classes in Smalltalk are arranged in the form of a tree. The class above a given class in the hierarchy is its superclass; classes below are its subclasses.

More information

Smalltalk FOOP. Smalltalk

Smalltalk FOOP. Smalltalk 2015-03-20 Smalltalk Smalltalk 2015-03-20 Smalltalk 1 First Examples hello Transcript show: Hi World hello5 1 to: 5 do: [:i (Transcript show: Hi World ) cr] hello: times 1 to: times do: [:i (Transcript

More information

Smalltalk. Topics. History of Smalltalk. OOP and GUI. Steve Jobs, PARC, Dec Smalltalk 1. The best way to predict the future is to invent it.

Smalltalk. Topics. History of Smalltalk. OOP and GUI. Steve Jobs, PARC, Dec Smalltalk 1. The best way to predict the future is to invent it. Smalltalk The best way to predict the future is to invent it. Alan Kay, 1971 Topics History and significance of Smalltalk Object-oriented programming The Smalltalk language Smalltalk today Additional Examples

More information

Object Oriented Paradigm Languages

Object Oriented Paradigm Languages Object Oriented Paradigm Languages The central design goal is to build inherent abstraction into the system, moving all the abstract implementation details from the user level (ad-hoc) to the system level

More information

ST Introduction. Birds-eye view

ST Introduction. Birds-eye view 3. Standard Classes ST Introduction Birds-eye view Reify everything by reifying its entire implementation model, Smalltalk succeeds in being open, and extensible. New features can be added without changing

More information

Basic Objects, Conditionals and Loops

Basic Objects, Conditionals and Loops Basic Objects, Conditionals and Loops Booleans Basic Loops Overview of the Collection hierarchy more than 80 classes: (Bag, Array, OrderedCollection, SortedCollection, Set, Dictionary...) Loops and Iteration

More information

References: Chapters 10 and 11 Chapters 8, and 12( 2 and 3)

References: Chapters 10 and 11 Chapters 8, and 12( 2 and 3) Topic V Object-oriented languages : Concepts and origins SIMULA and Smalltalk References: Chapters 10 and 11 of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapters 8, and 12( 2 and

More information

Simula 67. Simula and Smalltalk. Comparison to Algol 60. Brief history. Example: Circles and lines. Objects in Simula

Simula 67. Simula and Smalltalk. Comparison to Algol 60. Brief history. Example: Circles and lines. Objects in Simula CS 242 Simula 67 Simula and Smalltalk John Mitchell First object-oriented language Designed for simulation Later recognized as general-purpose prog language Extension of Algol 60 Standardized as Simula

More information

Object. Accessing. Changing. Chapter

Object. Accessing. Changing. Chapter Chapter 10 Object Smalltalk is a rooted system, which means that there is a root superclass from which all other classes are descended. That root superclass is Object. (Actually, there other root classes,

More information

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language Categories of languages that support OOP: 1. OOP support is added to an existing language - C++ (also supports procedural and dataoriented programming) - Ada 95 (also supports procedural and dataoriented

More information

An Introduction to Smalltalk for Objective-C Programmers

An Introduction to Smalltalk for Objective-C Programmers An Introduction to Smalltalk for Objective-C Programmers O Reilly Mac OS X Conference October 25 28, 2004 Philippe Mougin - pmougin@acm.org http://www.fscript.org IT Management & Consulting What you will

More information

Syntax and Messages. Stéphane Ducasse 8.1

Syntax and Messages. Stéphane Ducasse 8.1 Syntax and Messages The syntax of Smalltalk is simple and uniform, but it can look strange at first sight! Literals: numbers, strings, arrays... Variable names Pseudo-variables Assignments, returns Message

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

CS 403/503 Exam 4 Spring 2015 Solution

CS 403/503 Exam 4 Spring 2015 Solution CS 403/503 Exam 4 Spring 2015 Solution Each problem initially scored out of 10 points possible. CS 403 Best 5 answers doubled. (5*20 + 2*10 = 120 possible) CS 503 Best 4 answers doubled. (4*20 + 3*10 =

More information

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO

More information

Why using Smalltalk for Teaching Object- Oriented Design

Why using Smalltalk for Teaching Object- Oriented Design Why using Smalltalk for Teaching Object- Oriented Design N. Bouraqadi - Ecole des Mines de Douai S. Ducasse - University of Berne S. Stinckwich - University of Caen R. Wuyts - Université Libres de Bruxelles

More information

Dynamic Object-Oriented Programming with Smalltalk 1. Introduction

Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz Autumn Semester 2009 LECTURE TITLE What is surprising about Smalltalk > Everything is an object > Everything happens

More information

Guru 101 Grokking the Smalltalk system. Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group

Guru 101 Grokking the Smalltalk system. Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group Guru 101 Grokking the Smalltalk system Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group jpelrine@daedalos.de About this talk 10:00-12:00 AM Coffee break Beer afterwards Intermediate

More information

Simula and Smalltalk. Comparison to Algol 60. Brief history. Example: Circles and lines. Objects in Simula. John Mitchell

Simula and Smalltalk. Comparison to Algol 60. Brief history. Example: Circles and lines. Objects in Simula. John Mitchell CS 242 Simula 67 Simula and Smalltalk John Mitchell First object oriented language Designed for simulation Later recognized as general purpose prog language Extension of Algol 60 Standardized as Simula

More information

ST Introduction. Birds-eye view

ST Introduction. Birds-eye view 6. Debugging ST Introduction Birds-eye view It can be easier to talk to objects than to read classes The system is alive. Talk to it. The debugger can be your best friend. Donʼt be afraid of it. 1.2 Roadmap

More information

Some instance messages and methods

Some instance messages and methods Some instance messages and methods x ^x y ^y movedx: dx Dy: dy x

More information

CSE 452: Programming Languages. Previous Lecture. From ADTs to OOP. Data Abstraction and Object-Orientation

CSE 452: Programming Languages. Previous Lecture. From ADTs to OOP. Data Abstraction and Object-Orientation CSE 452: Programming Languages Data Abstraction and Object-Orientation Previous Lecture Abstraction Abstraction is the elimination of the irrelevant and the amplification of the essential Robert C Martin

More information

Terminology. Object-Orientation. Abstract syntax. Smalltalk

Terminology. Object-Orientation. Abstract syntax. Smalltalk Basic ideas: Object-Orientation data abstraction (may or may not hide information inheritance reuse of implementations subtyping reuse of interfaces ( protocols (disciplined dynamic binding of functions

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

fohgp siejt karbl mcqdn

fohgp siejt karbl mcqdn CS 403/503 Exam 4 Spring 2017 Solution CS 403 Score is based on your best 8 out of 10 problems. CS 503 Score is based on your best 9 out of 10 problems. Extra credit will be awarded if you can solve additional

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

The System Transcript, Class Point and Inspectors

The System Transcript, Class Point and Inspectors Module 4 1 Module 4: The System Transcript, Class Point and Inspectors This module starts by introducing the System Transcript, illustrating how it can be used with a number of examples. The Transcript

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 2: Review of Object Orientation 2.1 What is Object Orientation? Procedural paradigm: Software is organized

More information

9. Understanding Classes and Metaclasses

9. Understanding Classes and Metaclasses 9. Understanding Classes and Metaclasses ST Introduction Birds-eye view Reify your metamodel A fully reflective system models its own metamodel. 1.2 Roadmap > Metaclasses in 7 points > Indexed Classes

More information

LATENT METHODS. Richard CS

LATENT METHODS. Richard CS LATENT METHODS Richard O'Keefe @ CS Outline Background The problem Some non-solutions My solution Does it apply elsewhere Background Alan Kay invented tablet computers (the Dynabook) His research group

More information

Java: introduction to object-oriented features

Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Smalltalk: A White Paper Overview

Smalltalk: A White Paper Overview Smalltalk: A White Paper Overview Harry H. Porter III Department of Computer Science Portland State University March 24, 2003 Table of Contents Table of Contents...2 Introduction...4 Basic OOP Concepts

More information

2. Smalltalk a reflective language. Oscar Nierstrasz

2. Smalltalk a reflective language. Oscar Nierstrasz 2. Smalltalk a reflective language Oscar Nierstrasz Birds-eye view Smalltalk is still today one of the few fully reflective, fully dynamic, objectoriented development environments. We will see how a simple,

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

Chapter 10 Object-Oriented Programming

Chapter 10 Object-Oriented Programming Chapter 10 Object-Oriented Programming Software Reuse and Independence Objects, Classes, and Methods Inheritance and Dynamic Binding Language Examples: Java, C++, Smalltalk Design Issues and Implementation

More information

Functional programming in LISP

Functional programming in LISP Programming Languages Week 4 Functional programming in LISP College of Information Science and Engineering Ritsumeikan University review of part 3 enumeration of dictionaries you receive a sequence of

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

Smalltalk Implementation

Smalltalk Implementation Smalltalk Implementation Prof. Harry Porter Portland State University 1 The Image The object heap The Virtual Machine The underlying system (e.g., Mac OS X) The ST language interpreter The object-memory

More information

3. A Simple Counter. Creating your own class

3. A Simple Counter. Creating your own class In this exercise, you will write your first complete program. The program is very simple, the goal of the exercise is to get used to the Pharo environment and the basics of the language. From the Pharo

More information

CS 403/503 Exam 4 Spring 2017 Name

CS 403/503 Exam 4 Spring 2017 Name CS 403/503 Exam 4 Spring 2017 Name CS 403 Score is based on your best 8 out of 10 problems. CS 503 Score is based on your best 9 out of 10 problems. Extra credit will be awarded if you can solve additional

More information

Object-Oriented Software Engineering. Chapter 2: Review of Object Orientation

Object-Oriented Software Engineering. Chapter 2: Review of Object Orientation Object-Oriented Software Engineering Chapter 2: Review of Object Orientation 2.1 What is Object Orientation? Procedural paradigm: Software is organized around the notion of procedures Procedural abstraction

More information

2. Classes & Inheritance. Classes. Classes. Éric Tanter Objects and Design in Smalltalk. How do you create objects?

2. Classes & Inheritance. Classes. Classes. Éric Tanter Objects and Design in Smalltalk. How do you create objects? Objects and Design in Smalltalk 2. Classes & Inheritance Éric Tanter etanter@dcc.uchile.cl 1 Classes How do you create objects? Ex-nihilo in prototype-based languages With a class in class-based languages

More information

Object-oriented Programming. Object-oriented Programming

Object-oriented Programming. Object-oriented Programming 2014-06-13 Object-oriented Programming Object-oriented Programming 2014-06-13 Object-oriented Programming 1 Object-oriented Languages object-based: language that supports objects class-based: language

More information

Class 22: Inheritance

Class 22: Inheritance Menu Class 22: Inheritance Objects Review Object-Oriented Programming Inheritance CS50: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans 2 Objects When

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

More information

1 Reflection and Metaprogramming in Smalltalk

1 Reflection and Metaprogramming in Smalltalk Programming Language Design Matthias Springer, 15D54036 1 Abstract In this work, we present examples for metaprogramming using thiscontext and mixins and their implementation in Squeak/Pharo, both of which

More information

Chapter 11 Object and Object- Relational Databases

Chapter 11 Object and Object- Relational Databases Chapter 11 Object and Object- Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Outline Overview of Object Database Concepts Object-Relational

More information

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

CS508-Modern Programming Solved MCQ(S) From Midterm Papers (1 TO 22 Lectures) BY Arslan

CS508-Modern Programming Solved MCQ(S) From Midterm Papers (1 TO 22 Lectures) BY Arslan CS508-Modern Programming Solved MCQ(S) From Midterm Papers (1 TO 22 Lectures) BY Arslan April 18,2017 V-U For Updated Files Visit Our Site : Www.VirtualUstaad.blogspot.com Updated. MidTerm Papers Solved

More information

Syntax and Messages. Stéphane Ducasse S.Ducasse

Syntax and Messages. Stéphane Ducasse   S.Ducasse Syntax and Messages Stéphane Ducasse Stephane.Ducasse@univ-savoie.fr http://www.listic.univ-savoie.fr/~ducasse/ 1 License: CC-Attribution-ShareAlike 2.0 http://creativecommons.org/licenses/by-sa/2.0/ 2

More information

IEEE LANGUAGE REFERENCE MANUAL Std P1076a /D3

IEEE LANGUAGE REFERENCE MANUAL Std P1076a /D3 LANGUAGE REFERENCE MANUAL Std P1076a-1999 2000/D3 Clause 10 Scope and visibility The rules defining the scope of declarations and the rules defining which identifiers are visible at various points in the

More information

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017 SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

Comp 311 Principles of Programming Languages Lecture 21 Semantics of OO Languages. Corky Cartwright Mathias Ricken October 20, 2010

Comp 311 Principles of Programming Languages Lecture 21 Semantics of OO Languages. Corky Cartwright Mathias Ricken October 20, 2010 Comp 311 Principles of Programming Languages Lecture 21 Semantics of OO Languages Corky Cartwright Mathias Ricken October 20, 2010 Overview I In OO languages, data values (except for designated non-oo

More information

Object Oriented Discrete-Event Simulation with OOSimL CS 4632

Object Oriented Discrete-Event Simulation with OOSimL CS 4632 Object Oriented Discrete-Event Simulation with OOSimL CS 4632 Spring 2016 Dr. José M. Garrido Department of Computer Science College of Computing and Software Engineering Kennesaw State University Definitions

More information

25. Generic Programming

25. Generic Programming 25. Generic Programming Java Fall 2009 Instructor: Dr. Masoud Yaghini Generic Programming Outline Polymorphism and Generic Programming Casting Objects and the instanceof Operator The protected Data and

More information

Agora: Message Passing as a Foundation for Exploring OO Language Concepts

Agora: Message Passing as a Foundation for Exploring OO Language Concepts Agora: Message Passing as a Foundation for Exploring OO Language Concepts Wim Codenie, Koen De Hondt, Theo D'Hondt, Patrick Steyaert Programming Technology Lab (PROG/WE) Brussels Free University (VUB)

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

Lecture 16: Object Programming Languages

Lecture 16: Object Programming Languages Lecture 16: Object Programming Languages Introduction Corresponds to EOPL 5.1 and 5.2 Goal: to introduce Object Oriented Programming Language (OOPL) concepts using the EOPL extensible language framework

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Smalltalk: developed at Xerox Palo Alto Research Center by the Learning Research Group in the 1970 s (Smalltalk-72, Smalltalk-76, Smalltalk-80)

Smalltalk: developed at Xerox Palo Alto Research Center by the Learning Research Group in the 1970 s (Smalltalk-72, Smalltalk-76, Smalltalk-80) A Bit of History Some notable examples of early object-oriented languages and systems: Sketchpad (Ivan Sutherland s 1963 PhD dissertation) was the first system to use classes and instances (although Sketchpad

More information

Modern Programming Languages. Lecture LISP Programming Language An Introduction

Modern Programming Languages. Lecture LISP Programming Language An Introduction Modern Programming Languages Lecture 18-21 LISP Programming Language An Introduction 72 Functional Programming Paradigm and LISP Functional programming is a style of programming that emphasizes the evaluation

More information

Java Overview An introduction to the Java Programming Language

Java Overview An introduction to the Java Programming Language Java Overview An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/

More information

Java Fundamentals (II)

Java Fundamentals (II) Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class

More information

Section 5: Pascal. Evolution of Software Languages

Section 5: Pascal. Evolution of Software Languages Section 5: Pascal Evolution of Software Languages Theo D'Hondt Bachelor of Computer Science Faculty of Sciences and Bio-Engineering Sciences Vrije Universiteit Brussel Academic Year 2015-2016 Evolution

More information

11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT

11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT Functional programming FP Foundations, Scheme (2 In Text: Chapter 15 LISP: John McCarthy 1958 MIT List Processing => Symbolic Manipulation First functional programming language Every version after the

More information

CPS 506 Comparative Programming Languages. Programming Language

CPS 506 Comparative Programming Languages. Programming Language CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database Extensions to SQL ODMG Object Model and the Object Definition Language ODL Object Database Conceptual

More information

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

A Lazy List Implementation in Squeak

A Lazy List Implementation in Squeak A Lazy List Implementation in Squeak Takashi Yamamiya This material is based upon work supported in part by the National Science Foundation under Grant No. 0639876. Any opinions, findings, and conclusions

More information

Functional Programming. Pure Functional Programming

Functional Programming. Pure Functional Programming Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Babu Madhav Institute of Information Technology, UTU 2015

Babu Madhav Institute of Information Technology, UTU 2015 Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing?

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

A simple reflective object kernel

A simple reflective object kernel A simple reflective object kernel S. Ducasse The Pharo Booklet Collection edited by S. Ducasse November 20, 2017 master @ d4e4b4f* Copyright 2017 by S. Ducasse. The contents of this book are protected

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries 1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

About Instance Initialization

About Instance Initialization Learning Object-Oriented Programming and Design with TDD About Instance Initialization Stéphane Ducasse http://stephane.ducasse.free.fr http://www.pharo.org W5S06 W5S06 2 / 26 How to ensure that an instance

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT ORİENTATİON ENCAPSULATİON OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual

More information

Symbol Tables Symbol Table: In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is

More information

Abstract Interpretation for Dummies

Abstract Interpretation for Dummies Abstract Interpretation for Dummies Program Analysis without Tears Andrew P. Black OGI School of Science & Engineering at OHSU Portland, Oregon, USA What is Abstract Interpretation? An interpretation:

More information

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309 A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48

More information

CHAIN OF RESPONSIBILITY (DP 223)

CHAIN OF RESPONSIBILITY (DP 223) CHAIN OF RESPONSIBILITY (DP 223) Object Behavioral Intent Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects

More information

Week. Lecture Topic day (including assignment/test) 1 st 1 st Introduction to Module 1 st. Practical

Week. Lecture Topic day (including assignment/test) 1 st 1 st Introduction to Module 1 st. Practical Name of faculty: Gaurav Gambhir Discipline: Computer Science Semester: 6 th Subject: CSE 304 N - Essentials of Information Technology Lesson Plan Duration: 15 Weeks (from January, 2018 to April, 2018)

More information

This chapter describes some of the more common errors that Smalltalk programmers make and gives suggestions on how to prevent the errors.

This chapter describes some of the more common errors that Smalltalk programmers make and gives suggestions on how to prevent the errors. Chapter 22 Common Errors This chapter describes some of the more common errors that Smalltalk programmers make and gives suggestions on how to prevent the errors. Notifier window messages As you test your

More information

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives CS 61A Scheme Spring 2018 Discussion 7: March 21, 2018 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme

More information

Object Model. Object Oriented Programming Spring 2015

Object Model. Object Oriented Programming Spring 2015 Object Model Object Oriented Programming 236703 Spring 2015 Class Representation In Memory A class is an abstract entity, so why should it be represented in the runtime environment? Answer #1: Dynamic

More information

Subtyping (Dynamic Polymorphism)

Subtyping (Dynamic Polymorphism) Fall 2018 Subtyping (Dynamic Polymorphism) Yu Zhang Course web site: http://staff.ustc.edu.cn/~yuzhang/tpl References PFPL - Chapter 24 Structural Subtyping - Chapter 27 Inheritance TAPL (pdf) - Chapter

More information