self introduction
play

Self Introduction Dynamic Languages Day - PowerPoint PPT Presentation

Self Introduction Dynamic Languages Day Ellen.Van.Paesschen@vub.ac.be Programming Technology Lab - Vrije Universiteit Brussel Schedule Introduction to prototypes Important features of PBLs History of Self Selfs basics The power of Self


  1. Self Introduction Dynamic Languages Day Ellen.Van.Paesschen@vub.ac.be Programming Technology Lab - Vrije Universiteit Brussel

  2. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s basics The power of Self Dynamic Languages Day Efficiency References

  3. Introduction To Prototypes 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 “Using Prototypical Objects to Implement Shared Behavior in OO Systems“ “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” Dynamic Languages Day PBLs are class-less OO languages Most PBLs are dynamically typed (only Omega isn’t) Self , Kevo, Agora, NewtonScript, ...

  4. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s basics The power of Self Dynamic Languages Day Efficiency References

  5. Important Features of PBLs (1/3) Three ways to create new objects Cloning a prototype Creation ex-nihilo Dynamic Languages Day Extension

  6. Important Features of PBLs (2/3) Delegation or object-centered inheritance a prototypical Pen at (50,200) LOGO example t x e t *draw n r e o v c i searching... e n c a Pen at (100,200) i e 50 200 d r e l a t u x y n delegates to c i g e i x r o E 100 f o delegates to x self Dynamic Languages Day *forward a prototypical searching... Turtle at (25,200) 90 25 with heading 90 draw x heading

  7. Important Features of PBLs (3/3) Parent sharing *draw a Pen at self (50 , 200) (50 , 100) 50 200 100 x y 100 x Dynamic Languages Day a Pen at (100 , 200) (100 , 100) *forward *draw 90 (50 , 100) (50 , 200) a Turtle at heading y: 100 with heading 90

  8. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s basics The power of Self Dynamic Languages Day Efficiency References

  9. History of Designed by 1986 Ungar&Smith @ XEROX Initial implementation 1987 “Self: The Power of Simplicity” @Stanford @OOPSLA'87 Research vehicle 1990 1st Public release Moved to 1991 Stanford 1992 More public releases 1993 Researched@Sun Dynamic Languages Day Self 4.0 1995 today Self 4.2.1

  10. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s basics The power of Self Dynamic Languages Day Efficiency References

  11. Self’s Basics Visual exploratory programming environment Desktop An object Trash Input An object Dynamic Languages Day

  12. 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 Dynamic Languages Day Slots contain data or methods Assignable and constant data slots

  13. 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* Dynamic Languages Day Extension (concatenation) for state inheritance copy-down

  14. Self’s Basics Traits objects gather shared reusable behavior Convention draw Traits Pen Delegation via parent* pointer Dynamic Languages Day 50 200 50 200 50 200 x y x y x y a Pen a Pen prototypical Pen copy copy

  15. Self’s Basics Maps transparently group objects x offset Map for Pen y offset 50 200 100 200 20 30 Dynamic Languages Day prototypical Pen a Pen a Pen copy copy Clone family

  16. Self’s Basics Dynamic delegation Traits Turtle draw Traits DashedTurtle draw forward backward Dynamic Languages Day 50 200 x y 90 heading becomeDashed a Turtle at (50,200) with heading 90

  17. Self’s Basics Multiple inheritance Traits forward draw MovingTurtle Traits backward DrawingTurtle Dynamic Languages Day 50 200 x y 90 heading a Turtle at (50,200) with heading 90

  18. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s basics The power of Self Dynamic Languages Day Efficiency References

  19. a P The Power of Self Reflective meta-programming with mirrors 0 0 z asMirror 0 50 200 addSlots: |(z <- 0)| x y reflectee a mirror on a Pen a Pen Dynamic Languages Day Annotations Consulting size, parents, ... Changing structure Testing ...

  20. The Power of Self Example 1: Method overwriting asMirror draw = ( newBody ) draw = ( body ) draw=( body) at: ‘draw’ PutContents: draw=(new Body) Traits Pen (reflect:( newBody )) a mirror on Traits Pen Dynamic Languages Day 50 200 50 10 1 3 x y x y x y a Pen a Pen a Pen

  21. The Power of Self Example 2: Assignment shadowing (1/3) draw = ( body ) Traits Pen a Pen a Pen a Pen Dynamic Languages Day 50 200 50 10 1 3 x y x y x y Setters are automatically x: = ( ) x: = ( ) x: = ( ) provided per assignable slot ➔ ➔ ➔ y: = ( ) y: = ( ) y: = ( ) via a hidden data slot containing ➔ ➔ ➔ How to the assignment primitive intercept this x: ?

  22. The Power of Self Example 2: Assignment shadowing (2/3) How to override this x: ? x: = ( ) x: = ( ) x: = ( ) ➔ ➔ ➔ y: = ( ) y: = ( ) y: = ( ) ➔ ➔ ➔ x:5 50 200 50 10 1 3 x y x y x y a Pen a Pen a Pen asMirror Create a new object Dynamic Languages Day reflectee Add a parent link to original Pen x:val = ([new code] Change all references from original reflectee resend.x:val) Pen to new object Add new method possibly with super call a mirror on a Pen a Pen

  23. The Power of Self Example 2: Assignment shadowing (3/3) Six statements shadow: selector = ( |new . me| me: (reflect: self). Create a new object new: (reflect: (| |)). Add new method possibly with super call new at:(selector,':') PutContents: (('|:arg| resend.',selector, ': arg. \' new code \'.') parseObjectBody). Change all references from original Pen to new wrapper a new object (browse referencesOf: self)do:[ Dynamic Languages Day |:ref| (ref isFake) ifFalse:[(ref mirror)at:(ref storedName PutContents:new]]. Add a parent link to original Pen new at:(selector,'assignmentParent') PutContents: (reflect:self). (new at:(selector,'assignmentParent')) isParent: true.)

  24. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s character The power of Self Dynamic Languages Day Efficiency References

  25. Efficiency Is 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 Dynamic Languages Day Traits containing the intended behavior are ``guessed” during method lookup ≈ 2 * speed of optimised C

  26. Schedule Introduction to prototypes Important features of PBLs History of Self Self’s character The power of Self Dynamic Languages Day Efficiency References

  27. References Self 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 Corte http://research.sun.com/research/self/release_4.0/Self-4.0/Tutorial/index.html SelfSync: a RTE environment in Self http://prog.vub.ac.be/~ellenvp Self SWIKI Dynamic Languages Day http://www.merlintec.com:8080/Self Self Programmer’s Reference Manual Self folder /manuals

  28. 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, Dynamic Languages Day Chambers, Chang, Hölzle

  29. Dynamic Languages Day ??? Questions

  30. Dynamic Languages Day

  31. Dynamic Languages Day

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend