Pharo: A Reflective System
description
Transcript of Pharo: A Reflective System
![Page 2: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/2.jpg)
What is it?
Language + Environment
Simple Language (based on Smalltalk)
Object-Oriented, Dynamic, Reflective
Explore + Change running systems
!
The Ultimate Programming Environment!
![Page 3: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/3.jpg)
Pharo: Open SourceMIT license Mac, Linux, Windows (Android, iOS)
Great community Improving steadily Many excellent libraries
![Page 4: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/4.jpg)
Simple Language
![Page 5: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/5.jpg)
“Objective-C without C”
![Page 6: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/6.jpg)
Reflection
![Page 7: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/7.jpg)
Code (description)
![Page 8: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/8.jpg)
Description Running Program
![Page 9: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/9.jpg)
Description Running Program
![Page 10: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/10.jpg)
Definition: !
A reflective system is a system which incorporates causally connected structures representing (aspects of) itself.
!
(Patty Maes, OOPSLA 87)
![Page 11: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/11.jpg)
Introspection
Introspection
Self-representation can be queried
Intercession
Self-representation can be changed
!
Reflection = Introspection + Intercession
![Page 12: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/12.jpg)
Structure and Behavior
Structural Reflection
Concerned with static structure
packages, classes, methods…
Behavioral Reflection
Concerned with program execution
method execution, assignment, execution stack…
![Page 13: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/13.jpg)
Why?
![Page 14: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/14.jpg)
Future Systems…Complex: Runtime can not be ignored
Analyse at runtime
Live Programming
!
“Eternal” Evolution
Development does not stop after deployment
Enable evolution in deployment
![Page 15: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/15.jpg)
Live Programming: Development at Runtime
![Page 16: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/16.jpg)
Reflection is the basis
![Page 17: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/17.jpg)
Classes, Methods, Packages are Objects
![Page 18: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/18.jpg)
The tools manipulate these Objects
![Page 19: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/19.jpg)
Inspector
![Page 20: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/20.jpg)
Demo: Inspect World
![Page 21: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/21.jpg)
Demo: Changing a class at runtime
![Page 22: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/22.jpg)
Demo: Reflective Execution Stack
![Page 23: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/23.jpg)
Reflective Challenges
![Page 24: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/24.jpg)
Three Examples
• Partial Behavioral Reflection
• Controlling Reflection
• Reflection and the Virtual Machine
![Page 25: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/25.jpg)
Advanced Reflection
• Partial Behavioral Reflection
• Associate MetaObject with structural object
• e.g. methods, slots…
• AST nodes
![Page 26: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/26.jpg)
Partial Behavioral Reflection
• Change behaviour for selected AST Nodes
• “All assignments”
• “this message send”
But without changing the program code!
![Page 27: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/27.jpg)
Partial Behavioral Reflection
source code
(AST)
meta-object
activation
condition
links
![Page 28: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/28.jpg)
Uses…
• Debugger
• BreakPoints, WatchPoints
• Profilers
• Coverage Analysis
• AOP
![Page 29: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/29.jpg)
Reflection is dangerous
Everything is possible
!
!
Can we control the effect of Reflective Change?
Controlling Reflection
![Page 30: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/30.jpg)
Put “virtualization” in the language
!
We already use “Images”
!
Make the Image a first class concept in the language
System - as - Objects
![Page 31: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/31.jpg)
“traditional JIT”: per method translation to native code
!
Already fast, but slower than e.g JVM
!
Next Step: Type feedback runtime optimiser in the VM
A lot of work ==> not realistic
Pharo JIT Compiler
![Page 32: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/32.jpg)
We can stop execution
!
We can manipulate the stack
!
And then continue
Reflective Optimization
![Page 33: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/33.jpg)
Type Feedback JITSista
!
Work with E. Miranda
!
![Page 34: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/34.jpg)
Methods in Pharo are still Strings
!
Why not use a reflective model for methods?
!
Text editor modifies directly the objects, not text
Future: Beyond Text
![Page 35: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/35.jpg)
Open Pharo SprintsMay 2008 Bern July 2009 Bern October 2009 Lille November 2009 Buenos Ares March 2010 Bern May 2010 Buenos Ares June 2010 Bern June 2010 Bruxelles July 2010 London September 2010 Barcelona September 2010 Lille January 2011 Lille July 2011 Lille October 2011 Bruxelles February 2012 Bern April 2012 Lille September 2012 Ghent October 2013 Lille November 2013 Buenos Aires
!
![Page 36: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/36.jpg)
The next one is tomorrow!
!
14h Building B in front of B31
![Page 37: Pharo: A Reflective System](https://reader034.fdocuments.in/reader034/viewer/2022051400/554f98aab4c90586258b46c5/html5/thumbnails/37.jpg)
Picture on Slide 7:
Source code ON PAPER, available under Creative Commons
http://www.flickr.com/photos/toolmantim/6170448143/