self introduction - vrije universiteit...
TRANSCRIPT
![Page 1: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/1.jpg)
Self Introduction
[email protected] Technology Lab - Vrije Universiteit Brussel
Dyn
amic
Lan
guag
es D
ay
![Page 2: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/2.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s basics
The power of Self
Efficiency
References
![Page 3: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/3.jpg)
Dyn
amic
Lan
guag
es D
ay
Prototype theory is founded in the middle of the twentieth century as a response to the ancient class theory
In 1986 prototypes are introduced into the OO community by Lieberman in
“A prototype represents the default behavior for a concept”
“New objects can reuse (part of) the prototype’s knowledge by saying how the new object differs from the prototype”
PBLs are class-less OO languages
Most PBLs are dynamically typed (only Omega isn’t)
Self, Kevo, Agora, NewtonScript, ...
Introduction To Prototypes
“Using Prototypical Objects to Implement Shared Behavior in OO Systems“
![Page 4: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/4.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s basics
The power of Self
Efficiency
References
![Page 5: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/5.jpg)
Dyn
amic
Lan
guag
es D
ay
Important Features of PBLs (1/3)
Three ways to create new objects
Creation ex-nihilo
Extension
Cloning a prototype
![Page 6: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/6.jpg)
Dyn
amic
Lan
guag
es D
ay
Important Features of PBLs (2/3)
Delegation or object-centered inheritance
dele
gate
s to
a prototypicalTurtle at (25,200) with heading 90
*forward
x25
heading90
Execu
ted in
conte
xt
of ori
ginal
receiv
er
self
x100
a Pen at (100,200)
delegates to
searching...
y200
*draw
a prototypical Pen at (50,200)
x50
searching...
draw
LOGO example
![Page 7: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/7.jpg)
Dyn
amic
Lan
guag
es D
ay
Important Features of PBLs (3/3)
Parent sharing
200(50 , 200)
(100 , 200)
(50 , 200)
y: 100
100
(100 , 100)
(50 , 100)
(50 , 100)a Pen at
a Pen at
a Turtle at with heading 90
x y50
*draw
heading90
*draw*forward
x100
self
![Page 8: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/8.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s basics
The power of Self
Efficiency
References
![Page 9: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/9.jpg)
Dyn
amic
Lan
guag
es D
ay
History of 1986
1995
1993
1987
199219911990
Designed by Ungar&Smith @ XEROX
“Self: The Power of Simplicity”@OOPSLA'87
Initial implementation@Stanford
1st Public release Stanford Moved to
More public releases
Self 4.2.1
Self 4.0
Res
earc
h v
ehic
le
Res
earc
hed@
Sun
today
![Page 10: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/10.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s basics
The power of Self
Efficiency
References
![Page 11: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/11.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s BasicsVisual exploratory programming environment
Desktop
An object
Input
An object
Trash
![Page 12: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/12.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s Basics
Language features (1/2)
Syntax and semantics resemble those of Smalltalk
Blocks
Everything is an object
Manipulated via message sending
Objects consist of slots
Slots contain data or methods
Assignable and constant data slots
![Page 13: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/13.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s Basics
Language features (2/2)
Default creation is cloning prototype via copy
Creation ex-nihilo via slot definition, e.g. (|x . y <- 5|)
Delegation for behavioral inheritance
Through parent slots, e.g. parent1*
Extension (concatenation) for state inheritance
copy-down
![Page 14: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/14.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s BasicsTraits objects gather shared reusable behavior
Traits Pendraw
x y
50 200
prototypical Pen
Delegationvia parent* pointer
x y
a Pen
copy
50 200
x y
a Pen
copy
50 200
Conve
ntion
![Page 15: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/15.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s BasicsMaps transparently group objects
x
y
50 200
prototypical Pen a Pen
copy
100 200
a Pen
copy
20 30
Clone family
offset
offsetMap for Pen
![Page 16: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/16.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s BasicsDynamic delegation
becomeDashed
Traits Turtle
a Turtle at (50,200) with heading 90
x y50
draw
heading90
forward
200
backward
Traits DashedTurtledraw
![Page 17: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/17.jpg)
Dyn
amic
Lan
guag
es D
ay
Self’s BasicsMultiple inheritance
Traits MovingTurtle
a Turtle at (50,200) with heading 90
x y50
heading90
forward
200
Traits DrawingTurtle
draw backward
![Page 18: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/18.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s basics
The power of Self
Efficiency
References
![Page 19: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/19.jpg)
Dyn
amic
Lan
guag
es D
ay
The Power of SelfReflective meta-programming with mirrors
x y
50 200
a Pen
a Pen
reflectee
asMirror
addSlots: |(z <- 0)|
z 00
a mirror on a Pen
AnnotationsConsulting size, parents, ...
Changing structureTesting
...
0
![Page 20: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/20.jpg)
Dyn
amic
Lan
guag
es D
ay
The Power of SelfExample 1: Method overwriting
Traits Pendraw = (body)
x y
50 200
asMirror
a mirror on Traits Pen
draw=(newBody) at: ‘draw’ PutContents: (reflect:(newBody))
x y
a Pen
50 10
x y
a Pen
1 3
a Pen
draw=(body)draw = (newBody)
![Page 21: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/21.jpg)
Dyn
amic
Lan
guag
es D
ay
The Power of SelfExample 2: Assignment shadowing (1/3)
Traits Pen
draw = (body)
x y
50 200
x y
a Pen
50 10
x y
a Pen
1 3
a Pen
Setters are automatically provided per assignable slot
via a hidden data slot containingthe assignment primitive
x: = ( )y: = ( )
➔➔
x: = ( )y: = ( )
➔➔
x: = ( )y: = ( )
➔➔
How to intercept this x: ?
![Page 22: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/22.jpg)
Dyn
amic
Lan
guag
es D
ay
The Power of SelfExample 2: Assignment shadowing (2/3)
x y
50 200
x y
a Pen
50 10
x y
a Pen
1 3
x:val =([new code]
resend.x:val)
a Pen
a mirror on a Pen
asMirror
reflectee
a Pen
reflectee
Create a new object
Add a parent link to original Pen
Change all references from original Pen to new object
Add new method possibly with super call
x:5
x: = ( )y: = ( )
➔➔
x: = ( )y: = ( )
➔➔
x: = ( )y: = ( )
➔➔
How to override this x: ?
![Page 23: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/23.jpg)
Dyn
amic
Lan
guag
es D
ay
The Power of SelfExample 2: Assignment shadowing (3/3)
Create a new object
Add a parent link to original Pen
Change all references from original Pen to new wrapper a new object
Add new method possibly with super call
Six statementsshadow: selector = (|new . me|me: (reflect: self).
new: (reflect: (| |)).
new at:(selector,':') PutContents:(('|:arg| resend.',selector, ': arg. \'new code\'.') parseObjectBody).
(browse referencesOf: self)do:[|:ref| (ref isFake) ifFalse:[(ref mirror)at:(ref storedName PutContents:new]].
new at:(selector,'assignmentParent') PutContents: (reflect:self).(new at:(selector,'assignmentParent')) isParent: true.)
![Page 24: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/24.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s character
The power of Self
Efficiency
References
![Page 25: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/25.jpg)
Dyn
amic
Lan
guag
es D
ay
EfficiencyIs Self slow?
Significant optimisations of the Self compiler by Chambers and Hölzle @ Sun
Branch prediction
Optimisation of the fetch-decode-execute processor cycle for branch instructions
Inline caching
Traits containing the intended behavior are ``guessed” during method lookup
≈ 2 * speed of optimised C
![Page 26: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/26.jpg)
Dyn
amic
Lan
guag
es D
ay
Schedule
Introduction to prototypes
Important features of PBLs
History of Self
Self’s character
The power of Self
Efficiency
References
![Page 27: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/27.jpg)
Dyn
amic
Lan
guag
es D
ay
ReferencesSelf homepage http://research.sun.com/research/self
Self 4.2.1 http://research.sun.com/research/self/release_4.2/release.html
Self online tutorial - Wolzcko, De Cortehttp://research.sun.com/research/self/release_4.0/Self-4.0/Tutorial/index.html
SelfSync: a RTE environment in Selfhttp://prog.vub.ac.be/~ellenvp
Self SWIKIhttp://www.merlintec.com:8080/Self
Self Programmer’s Reference Manual
Self folder /manuals
![Page 28: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/28.jpg)
Dyn
amic
Lan
guag
es D
ay
References
Programming as an Experience: The Inspiration for Self (1995) - Smith, Ungar
Self: The Power of Simplicity (1987) - Ungar, Smith
Parents are Shared Parts: Inheritance and Encapsulation in Self (1991) - Chambers, Ungar, Chang, Hölzle
Organizing Programs Without Classes (1991) - Ungar, Chambers, Chang, Hölzle
![Page 29: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/29.jpg)
Dyn
amic
Lan
guag
es D
ay
Questions
???
![Page 30: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/30.jpg)
Dyn
amic
Lan
guag
es D
ay
![Page 31: Self Introduction - Vrije Universiteit Brusselsoft.vub.ac.be/events/2005/BADL/DLD/slides/DLD-Self.pdf · Introduction To Prototypes “Using Prototypical Objects to Implement Shared](https://reader033.vdocuments.site/reader033/viewer/2022050214/5f605b615530f65a9278e97a/html5/thumbnails/31.jpg)
Dyn
amic
Lan
guag
es D
ay