Ambient-Oriented Programming
Designing an Object-Oriented Language for Ambient Intelligence
Presented at the JCC 2005. (c) E. Tanter, All Rights Reserved
Dr. Éric TanterUniversity of Chile
DCC/CWR
1
Éric Tanter - JCC 2005 - [email protected]
Contents
• What is Ambient Intelligence (AmI)?
• OO Language Design for AmI
• AmbientTalk - A First OO Language for AmI
• Future Directions
2
Éric Tanter - JCC 2005 - [email protected]
Credits
Wolfgang de Meuter“Move Considered Harmful -- A Language Design Approach to Distribution and Mobility in Open Networks”PhD Thesis, 2004
Programming Technology Lab - Vrije Universiteit BrusselProf. Dr. Theo D’Hondt
Jessie Dedecker, Tom Van Cutsem, Stijn MostinckxPhD students (VUB), AmbientTalk development
Sebastián GonzálezPhD student (UCL)
ORION: Open Reflective Infrastructure for Open NetworksProject DCC/CWR - VUB2006-2007
3
Ambient Intelligence
A Peculiar Context for Application Development
[Dedecker+05b]
4
Éric Tanter - JCC 2005 - [email protected]
Hardware Environment
• Advent of mobile networks
• wireless technologies (wifi, bluetooth)
• nomadic and ad hoc (aka. open networks)
• Mobile devices
• limited connection range and computational resources
• Ambient Intelligence
• European Council’s IST Advisory Group [ISTAG03]
• aka. ubiquitous computing [Weiser91], pervasive computing
what is fundamentally different?
5
Éric Tanter - JCC 2005 - [email protected]
Autonomicity & Concurrency
Interconnected via ad hoc wireless networks
Communication
Autonomous Concurrent Devices
no central server natural concurrency
6
Éric Tanter - JCC 2005 - [email protected]
Connection Volatility
Volatile Wireless Connections
Devices frequently disconnect
Failure
cannot assume stable connection
but tasks need to be done
exceptions are no more exceptional!7
Éric Tanter - JCC 2005 - [email protected]
Resource Discovery
Ambient Resources
Devices (dis)appear in the 'Ambient'
Spontaneous Service Discovery
I require a
printing service
I provide a
printing service
Discovery
resources depend on location
8
Éric Tanter - JCC 2005 - [email protected]
Programming for AmI
• A robust AmI application must address these characteristics
• Current alternatives
• Middleware
• Distributed programming languages
DiscoveryFailureCommunication
9
Éric Tanter - JCC 2005 - [email protected]
Middleware• RPC-based middleware
• Alice [Haarh+99], Dolmen [Reynolds+99]
• CORBA on lightweight devices
• no support for long disconnections
• Publish-subscribe middleware [Cugola+02]
• good for context-aware communication
• forces callback programming
• Tuple-space based middleware [Murphy+01]
• uncoupling in both time and space
• not object-oriented10
Éric Tanter - JCC 2005 - [email protected]
Distributed Languages
• Languages for LAN
• Emerald [Jul+88], Obliq [Cardelli95], etc.
• communication mechanisms assume reliable connection
• Languages for open networks
• Janus [Kahn+90], Salsa [Varela+98], E [Miller]
• pure asynchronous communication
• no support for resource discovery
11
Éric Tanter - JCC 2005 - [email protected]
Position Statement
• Currently insufficient support for programming nomadic / ad hoc distributed systems
• low-level APIs, middleware, etc.
• can be done, but hard
• no dedicated abstractions for AmI specificities
• Need of dedicated languages: AmOP
[Dedecker+05]
“abstracting without hiding”
12
Object-Oriented Languages for AmI
13
Éric Tanter - JCC 2005 - [email protected]
Design Dimensions
object modelclass-based vs. prototype-based
static typing vs. dynamic typing
communication modelconcurrency model
communication primitives
failure handling
acquaintance management
14
Why Classes Do Not Fitand neither static typing...
[Gonzales+04]
15
Éric Tanter - JCC 2005 - [email protected]
OOP without classes??
object=
encapsulated state +
message passing
objects are goodencapsulation and polymorphism are
fundamental for highly dynamic environments
16
Éric Tanter - JCC 2005 - [email protected]
OOP without classes???
• Classification of OOP languages [Wegner87]
• object-based (objects + messages)
• class-based (classes)
• object-oriented (classes + inheritance)
• prototype-based (objects + delegation/sharing)
• ...
17
Éric Tanter - JCC 2005 - [email protected]
Fundamental Problem
Classesa static, implicit sharing mechanism of state and behaviour[Treaty of Orlando]
Distribution transparency is impossible to achieve in practice, and precisely because of that
impossibility, it is dangerous to provide the illusion of transparency.
[Guerraoui&Fayad99]
Open Networks
[Gonzales+04]
18
Éric Tanter - JCC 2005 - [email protected]
State Sharing
• class attributes (eg. Java statics)
• semantics = value shared by all instances
not true under distribution!
public static-replicated synchronized Vector v;protected static-centralized String s;
Solution: add yet more keywords to Java...
or fix a choice and make it implicit in the language.
It’s no solution: a new node may appear with the same class, but with a different value....
19
Éric Tanter - JCC 2005 - [email protected]
Code Sharing
• Exactly same issue with methods
A node containing the same class as another node may appear in the network, but with a different method
implementation...
Methods are part of a class’s state,just the same as class attributes.
If a method changes, the class is no longer the same, even if semantically it remains compatible.
20
Éric Tanter - JCC 2005 - [email protected]
Transitive Closuresinstance-of link + subclass-of link
when an object is transmitted, its class and all superclasses must be transmitted too
(an object is not a self-contained entity!)
static typing
transmit argument-type classes, return-type class and exception-type classesand their transitive closures
21
Éric Tanter - JCC 2005 - [email protected]
Conclusion on Classes
Classes (and static typing) are a barrier to adaptability
Classes are dangerous under distribution
sharing is important, but should be managed explicitly
prototype-based languages!
22
Éric Tanter - JCC 2005 - [email protected]
Prototypes• eg. Self [Ungar+87]
• Self-contained objects
• state + code
• created ex-nihilo or by cloning
• Extension mechanism
• true delegation to parent
• Sharing mechanism
• parent sharing
• managed explicitly
• eg. traits
self
self
message forwarding
delegation
[Ungar+91]
23
Communication Model
[Dedecker+05b]
24
Éric Tanter - JCC 2005 - [email protected]
Communication Primitives• Blocking primitives are evil
• deadlocks & diminished availability of resources
Non-blocking Asynchronous Communication Primitives
Based on Actors (Agha, 1986)
send
transmit
receive
Communication
26
Éric Tanter - JCC 2005 - [email protected]
Failure Recovery• Inconsistent states cannot be avoided
• need for reversibility
Reified Communication Traces
E.g. rollback strategies for failure recovery
agenda slot
available?yes
reservation
confirmed?
reserve slotAgendaActor
AgendaActor
Failure
AgendaActor
AgendaActor
rollback strategiesdelivery guarantees
27
Éric Tanter - JCC 2005 - [email protected]
Acquaintance Management• No third party for communication (P2P)
• no explicit reference: distributed naming
Actors specify services required from and provided to the ambient
Provided service patterns
Required service patterns
description of service interface
Discovery
Reified Environmental Context
actors specify servicesrequired from the ambientprovided to the ambient
28
Éric Tanter - JCC 2005 - [email protected]
Design Conclusions
Classless language, dynamically-typed
Actor model
Non-blocking communication primitives
Reified communication trace
Reified ambient context
C? C++? Java? C#?29
AmbientTalkA First AmOP Language
[Dedecker+05a]
30
Éric Tanter - JCC 2005 - [email protected]
Tested and deployed on QTek9090 PocketPC smartphones
VM runs on Java J2SE and J2ME platforms
Dynamically typed language
Prototype-based object model
Actor-based concurrency model
Plug-and-play: no additional setup
VMs communicate via sockets over WLAN
AmbientTalk VM
Actors
jat
http://prog.vub.ac.be/amop
AmbientTalk
31
Éric Tanter - JCC 2005 - [email protected]
«outbox»
«sentbox»
«inbox»
«rcvbox»
Communication Mailboxes reify actor-actor interaction
Communication
32
Éric Tanter - JCC 2005 - [email protected]
«joinedBox»
«required»
«provided»
«disjoinedBox»
Discovery Mailboxes reify actor-ambient interaction
Discovery
33
Éric Tanter - JCC 2005 - [email protected]
First-class Mailboxes
Meta-level events trapped using mailbox observers
interaction between mailboxes goverened by a metaobject protocol
onDisjoin
onJoin
onProcess
onReceipt
onTransmit
onSend
Metaobjects
34
Éric Tanter - JCC 2005 - [email protected]
AmbientTalk VM
Actors
jat
PrintFileBehavior :: object({ printer : void; file : void;
new(aFile,dpi) :: copy({ printer := AmbientRef("Printer"); file := aFile });
printIt() :: { when(printer#print(file), { display("Doc Printed!”) }) }})
PrintFileActor(file,dpi) :: { actor(PrintFileBehavior.new(file,dpi))}
{ p: PrintFileActor(aFile,300); p#printIt() }
35
Éric Tanter - JCC 2005 - [email protected]
Higher-level Constructs
• AmI is a moving target
• AmbientTalk is a testbed for AmOP experimentation
• Some higher-level constructs
• Non-blocking futures
• Application-specific message routing
• Group communication
• ...
[Dedecker+05a]
36
Éric Tanter - JCC 2005 - [email protected]
Language-level Security
• Security must be addressed at all levels
• comm. channels, OS, language, application, user
• Extreme encapsulation principle
• objects subject to message passing alone
• no “omnipotent operators”
• But powerful object model
• cloning, extension, parent sharing, reflection
• eg. mirror methods [Tanter05]
[DeMeuter+05]
37
Éric Tanter - JCC 2005 - [email protected]
Mobility
• Controversial feature
• Security-wise challenging
• A killer application? follow-me applications?
[Vallejos05]
38
Éric Tanter - JCC 2005 - [email protected]
Open Infrastructure
• Reflective Virtual Machine for AmI
• Fine-tune tradeoffs/strategies at the VM level
• garbage collection
• failure recovery strategy
• partial reversible computation
• partial object matching for resource discovery
[ORION]
39
Éric Tanter - JCC 2005 - [email protected]
Context Awareness
• Context-aware object references [VanCutsem+05]
• Context-oriented programming [Costanza+05]
• Context-aware aspects [Tanter+05]
40
References (1)
[Agha86] G. Agha, Actors: a model of concurrent computation in distributed systems, MIT Press 1986.
[Cardelli95] L. Cardelli, Obliq: a language with distributed scope, Proceedings of POPL 1995.
[Costanza+05] P. Costanza, R. Hirschfeld, Language Constructs for Context-Oriented Programming, Proceedings of DLS 2005.
[Cugola+02] G. Cugola, H.-A. Jacobsen, Using Publish-Subscribe Middleware for Mobile Systems, SIGMOBILE Mob. Comp. Commun. 6(4), 2002.
[Dedecker+05a] J. Dedecker, S. Mostinckx, T. Van Cutsem, W. De Meuter, T. D’Hondt, AmbientTalk: A Small Reflective Kernel for Programming Mobile Network Applications, VUB TR 2005.
[Dedecker+05b] J. Dedecker, T. Van Cutsem, S. Mostinckx, W. De Meuter, T. D’Hondt, Ambient-Oriented Programming, OOPSLA Onward! 2005.
[DeMeuter+05] W. De Meuter, É. Tanter, S. Mostinckx, T. Van Cutsem, J. Dedecker, Flexible Object Encapsulation for Ambient-Oriented Programming, Proceedings of DLS 2005.
[Guerraoui&Fayad99] R. Guerraoui, M. E. Fayad, OO Distributed Programming is Not Distributed OO Programming, CACM 42(4), 1999.
[Gonzales+04] S. Gonzalez, W. De Meuter, K. Mens, T. D’Hondt, The Unavoidable Failure of Class-Based Languages n the Processor Cloud Era, ECOOP Workshop on Object-Oriented Language Engineering for the Post-Java Era, 2004.
[Haarh+99] M. Haarh, R. Cunningham, V. Cahill, Supporting CORBA Applications in a Mobile Environment, Proceedings MobiCom 1999.
[ISTAG03] ISTAG, Ambient Intelligence: From Vision to Reality, http://www.corids.lu/ist/istag.htm, 2003.
[Jul+88] E. Jul, H. Levy, N. Hutchinson, A. Black, Fine-grained Mobility in the Emerald System, ACM TCS 6(1), 1988.
41
References (2)[Kahn+90] K.M. Kahn, V.A. Saraswat, Actors as a special case of concurrent constraint programming, Proceedings ECOOP/OOPSLA 1990.
[Miller] M. Miller, E: Open Source Distributed Capabilities, http://www.erights.org
[Murphy+01] A.L. Murphy, G.P. Picco, G.-C. Roman, Lime: A Middleware for Physical and Logical Mobility, Proceedings DCS 2001.
[ORION] Open Reflective Infrastructure for Open Networks, draft proposal for a bilateral project between the VUB Prog Lab and the DCC U. Chile, 2006-2007.
[Reynolds+99] P. Reynolds, R. Brangeon, DOLMEN - Service Machine Development for Open Long-Term Mobile and Fixed Network Environment. 1999.
[Tanter05] É. Tanter, Mirror Methods - Reconciling Reflection and Extreme Encapsulation, Proc. OT4AmI 2005.
[Tanter+05] É .Tanter, K. Gybels, M. Denker, A. Bergel, Context-Aware Aspects, DCC U.Chile TR 2005.
[Treaty of Orlando] H. Lieberman, L. Stein, D. Ungar, Treaty of Orlando, OOPSLA Add. 1987.
[Ungar+87] D. Ungar, R. Smith, Self: the Power of Simplicity, Proc. OOPSLA 1987.
[Ungar+91] D. Ungar, C. Chambers, B. Chang, U. Hölzle, Organizing Programs without Classes, Lisp Symb. Comp. 4(3), 1991.
[Vallejos05] J. Vallejos, Mobile Actors Supporting Reconfigurable Applications in Open P2P Networks, MSc Thesis, VUB, Belgium, 2005.
[Varela+98] C.A. Varela, G. Agha, What after Java? From Objects to Actors, Proceedings ICWWW 1998.
[VanCutsem+05] T. Van Cutsem, J. Dedecker, S. Mostinckx, W. De Meuter, Abstractions for Context-aware Object References, OOPSLA Workshop on Pervasive Computing, 2005.
[Wegner87] P. Wegner, Dimensions of Object-based Language Design, Proceedings OOPSLA 1987.
[Weiser91] M. Weiser, The Computer for the 21st Century, Scientific American 265(3) 1991.
42
Top Related