• No results found

Ambient-oriented Programming & AmbientTalk

N/A
N/A
Protected

Academic year: 2021

Share "Ambient-oriented Programming & AmbientTalk"

Copied!
83
0
0

Loading.... (view fulltext now)

Full text

(1)

Software Languages Lab

Brussels, Belgium

Ambient-oriented Programming

& AmbientTalk

Tom Van Cutsem Stijn Mostinckx Elisa Gonzalez Boix

(2)

Agenda

• Context: Mobile & Ubiquitous computing • Approach: Ambient-oriented programming • Tool: AmbientTalk

• Experiments: Demo applications

(3)

Mobile & Ubiquitous Computing

(4)

Ubiquitous Computing

• Research vision postulated by Mark Weiser (1988, Xerox PARC)

(5)

Today’s Applications

Smart Homes/Domotics

RFID Inventory Management

Tourism/City Guide Software

Personal Area Networks

(6)

Issues

• Software Issues:

• Context-awareness

• Interaction with real world

• Portability

• New user interfaces

• Standards

• Distributed Applications

• Hardware Issues:

• Miniaturisation

• Device Autonomy

• Interoperability

• Processor Speed

• Limited Memory

• Integration

• Cost

6

(7)

Issues

• Software Issues:

• Context-awareness

• Interaction with real world

• Portability

• New user interfaces

• Standards

• Distributed Applications

• Hardware Issues:

• Miniaturisation

• Device Autonomy

• Interoperability

• Processor Speed

• Limited Memory

• Integration

• Cost

6

(8)

Mobile Ad Hoc Networks

Networks composed of mobile devices that communicate wirelessly

(9)

Mobile Ad Hoc Networks

Networks composed of mobile devices that communicate wirelessly

7

Zero

(10)

Mobile Ad Hoc Networks

Networks composed of mobile devices that communicate wirelessly

7

Volatile

Connections

Zero

(11)

Ambient-oriented Programming

(12)

Observation #1: interaction with proximate peers

9

Example: match making between proximate peers

offer

type = Concert Ticket ticket.artist = “U2”

demand

type = Concert Ticket ticket.artist = “U2”

(13)

Observation #1: interaction with proximate peers

9

Example: match making between proximate peers

offer

type = Concert Ticket ticket.artist = “U2”

ticket.location = “Hyde Park”

demand

type = Concert Ticket ticket.artist = “U2”

(14)

Observation #1: interaction with proximate peers

9

Example: match making between proximate peers

offer

type = Concert Ticket ticket.artist = “U2”

ticket.location = “Hyde Park”

demand

type = Concert Ticket ticket.artist = “U2”

ticket.location = *

No reliance on fixed,

always-available server infrastructure

(15)

Observation #2: intermittent connectivity

(16)

Observation #2: intermittent connectivity

(17)

Observation #2: intermittent connectivity

(18)

Observation #2: intermittent connectivity

Tolerate disconnections, because they occur

frequently rather than exceptionally

(19)

Software concerns

11

(20)

Software concerns

11

uMaMa

(21)

Software concerns

11

uMaMa

(22)

Software concerns

11

uMaMa

Discovery Communication Synchronisation

21%

(23)

Software concerns

12

uMaMa

(24)

Software concerns

12

uMaMa

Failure handling

(25)

AmbientTalk

(26)

• Object-oriented scripting language

• Started in 2005

• Pure implementation

• Runs on J2ME/CDC phones

• Open source implementation

AmbientTalk: fact sheet

14

(27)

How does AmbientTalk help?

15

Volatile Connections

network connections are

resilient to failures by default

Zero Infrastructure

service discovery protocol

built into the language

(28)

Object-oriented

16

def makeSong(artist, title) {

object: {

def printArtist() {

if: (artist == nil) then: {

“unknown artist”; } else: { artist; } } } }

(29)

Object-oriented

16

def makeSong(artist, title) {

object: {

def printArtist() {

if: (artist == nil) then: {

“unknown artist”; } else: { artist; } } } }

def song := makeSong(“U2”, “One”);

(30)

Event Loop Concurrency

• AmbientTalk programs are event loops

• They react to events from the outside world • They communicate asynchronously

17

Event

Event Queue

(31)

Examples of event loops

• GUI Frameworks (e.g. Java AWT)

• Highly interactive applications (e.g. games) • IPC in Operating Systems

• Discrete Event Modelling (e.g. simulations) • Web servers

(32)

Event Loop Concurrency in AmbientTalk

(33)

Event Loop Concurrency in AmbientTalk

19

Event Loop

(34)

Event Loop Concurrency in AmbientTalk

19

(35)

Event Loop Concurrency in AmbientTalk

19

(36)

Event Loop Concurrency in AmbientTalk

(37)

Event Loop Concurrency in AmbientTalk

20

“do m immediately”

obj

(38)

Event Loop Concurrency in AmbientTalk

20

“do m eventually”

(39)

Event Loop Concurrency in AmbientTalk

20

“do m eventually”

(40)

Event Loop Concurrency in AmbientTalk

20

?

(41)

Event Loop Concurrency in AmbientTalk

20

?

future

when: future becomes: { |value| // process reply

(42)

Event Loop Concurrency in AmbientTalk

20

?

future

when: future becomes: { |value| // process reply

(43)

Exporting & discovering objects

21

(44)

Exporting & discovering objects

21

mplayer

(45)

Exporting & discovering objects

21

mplayer

export: mplayer as: MusicPlayer

(46)

Exporting & discovering objects

21

mplayer

export: mplayer as: MusicPlayer

whenever: MusicPlayer discovered: { |mplayer| // open a session

}

(47)

Exporting & discovering objects

21

mplayer

export: mplayer as: MusicPlayer

whenever: MusicPlayer discovered: { |mplayer| // open a session

}

(48)

Far References

22

session uploadSong

(49)

Far References

22

session uploadSong

(50)

Far References

22

session uploadSong

(51)

Far References

22

(52)

Far References

22

(53)

Far References

22

(54)

Far References

22

session

when: session<-uploadSong(s)@Due(timeout) becomes: { |ack| // continue exchange

} catch: TimeoutException using: { |e| // stop exchange

(55)

Leasing

23 Connected (messages are forwarded) Disconnected (messages are buffered) Expired (messages are dropped) reconnect expire expire disconnect session lease: 10.minutes

(56)

Reacting to failures

24 Connected (messages are forwarded) Disconnected (messages are buffered) Expired (messages are dropped) reconnect expire expire disconnect session lease: 10.minutes

(57)

Reacting to failures

24 Connected (messages are forwarded) Disconnected (messages are buffered) Expired (messages are dropped) reconnect expire expire disconnect

when: session disconnected: { // pause transmission

}

session

(58)

Reacting to failures

24 Connected (messages are forwarded) Disconnected (messages are buffered) Expired (messages are dropped) reconnect expire expire disconnect

when: session disconnected: { // pause transmission

}

when: session reconnected: { // resume transmission

}

session

(59)

Reacting to failures

24 Connected (messages are forwarded) Disconnected (messages are buffered) Expired (messages are dropped) reconnect expire expire disconnect

when: session disconnected: { // pause transmission

}

when: session reconnected: { // resume transmission

}

when: session expired: { // stop transmission }

session

(60)

Reacting to failures

24 Connected (messages are forwarded) Disconnected (messages are buffered) Expired (messages are dropped) reconnect expire expire disconnect

when: session disconnected: { // pause transmission

}

when: session reconnected: { // resume transmission

}

when: session expired: { // stop transmission }

when: session expired: { // clean up resources }

session

(61)

when: type discovered: { |obj| ... }

when: obj disconnected: { ... }

when: obj reconnected: { ... }

when: obj expired: { ... }

when: 5.minutes elapsed: { ... }

when: future becomes: { |result| ... }

whenever: type discovered: { |obj| ... }

whenever: obj disconnected: { ... }

whenever: obj reconnected: { ... }

whenever: 5.minutes elapsed: { ... }

Event Notifications

(62)

Discovery

when: type discovered: { |obj| ... }

when: obj disconnected: { ... }

when: obj reconnected: { ... }

when: obj expired: { ... }

when: 5.minutes elapsed: { ... }

when: future becomes: { |result| ... }

whenever: type discovered: { |obj| ... }

whenever: obj disconnected: { ... }

whenever: obj reconnected: { ... }

whenever: 5.minutes elapsed: { ... }

Event Notifications

(63)

Failure Handling

when: type discovered: { |obj| ... }

when: obj disconnected: { ... }

when: obj reconnected: { ... }

when: obj expired: { ... }

when: 5.minutes elapsed: { ... }

when: future becomes: { |result| ... }

whenever: type discovered: { |obj| ... }

whenever: obj disconnected: { ... }

whenever: obj reconnected: { ... }

whenever: 5.minutes elapsed: { ... }

Event Notifications

(64)

Synchronisation

when: type discovered: { |obj| ... }

when: obj disconnected: { ... }

when: obj reconnected: { ... }

when: obj expired: { ... }

when: 5.minutes elapsed: { ... }

when: future becomes: { |result| ... }

whenever: type discovered: { |obj| ... }

whenever: obj disconnected: { ... }

whenever: obj reconnected: { ... }

whenever: 5.minutes elapsed: { ... }

Event Notifications

(65)

AmbientTalk Program

Language Interoperability

• Scripting language on top of the JVM, cfr. JRuby, Jython, Groovy, ... • AmbientTalk can use Java libraries, Java can use AmbientTalk scripts

26

Java Virtual Machine

(66)

Batteries Included

27

def Button := jlobby.java.awt.Button;

def button := Button.new(“Click Me”);

button.addActionListener(object: {

def actionPerformed(actionEvent) {

println(“button clicked”); }

});

(67)

Reflection

• AmbientTalk code can introspect and change behavior of objects and actors

28

def makeSong(artist, title) { object: {

def printArtist() {

if: (artist == nil) then: { “unknown artist”; } else: { artist; } } } }

def song := makeSong(“U2”, “One”); song.printArtist();

(68)

Reflection

• AmbientTalk code can introspect and change behavior of objects and actors

28

def mirrorOnSong := (reflect: song); mirrorOnSong.invoke(song,

createInvocation(`printArtist, [])); mirrorOnSong.listSlots();

mirrorOnSong.addSlot(slot); ...

def makeSong(artist, title) { object: {

def printArtist() {

if: (artist == nil) then: { “unknown artist”; } else: { artist; } } } }

def song := makeSong(“U2”, “One”); song.printArtist();

(69)

Implementation

• Interactive interpreter • ± 17.000 SLOC of

• UDP & TCP/IP over WLAN • Runs on top of J2ME/CDC

• QTek 9090 SmartPhones

• HTC Touch Cruise SmartPhones • iPhone [in progress]

• Android G1 [in progress]

(70)

Demo Applications

(71)

Case: Musical Match Maker

• Demo

(72)

Experimental Results

(73)

Experimental Results

(74)

Causes

• Explicit encoding of

• buffered, asynchronous communication using threads • remote messages using objects

• timeouts using timer threads

• event notifications (lease expiration & renewal, calls & callbacks) using listeners + event loop threads

• Java RMI does not deal with service discovery

(75)

Case: Instant Messenger

• Demo

(76)

Chat: Java vs AmbientTalk (LoC)

(77)

Chat: Java vs AmbientTalk (%)

(78)

A simple application but...

... we do not need to explicitly manage:

threads & locks

low-level socket connections

stubs, skeletons

name server or lookup service

timeouts, leasing

(79)

• Implementation of the Morphic UI framework from Self • Demo: PortalPong

AmbientMorphic

(80)

Conclusion

• Mobile ad hoc networks:

• Ambient-oriented programming: • AmbientTalk:

• Scripting language on top of the JVM

• Reactive, event-driven programs

• Applications: chat, match maker, multiplayer game

(81)

Conclusion

• Mobile ad hoc networks:

• Ambient-oriented programming: • AmbientTalk:

• Scripting language on top of the JVM

• Reactive, event-driven programs

• Applications: chat, match maker, multiplayer game

40

Volatile Connections Zero Infrastructure

(82)

Conclusion

• Mobile ad hoc networks:

• Ambient-oriented programming: • AmbientTalk:

• Scripting language on top of the JVM

• Reactive, event-driven programs

• Applications: chat, match maker, multiplayer game

40

Volatile Connections Zero Infrastructure

Tolerate disconnections Peer-to-peer

(83)

Don’t program the

hardware

of the

future

with the

software

of the

past

References

Related documents

The analysis of Malawian groundnut production using the Policy Analysis Matrix methodology shows that both traditional and improved technology groundnut production are both

' What green-colored messages mean and how can turn on iMessage If your iPhone messages are deduct it means that they're have sent as SMS text messages rather sensitive as

Therefore our goal is to have the source node select carrier nodes in every direction (as the position and direction of movement of the disconnected destination is not known) and

Select Delete expired items (e-mail folders only) if you want messages to be deleted when they expire (six months for the Inbox and Drafts; three months for Sent Items) instead

Email short for electronic mail is one of the most widely used features of the Internet along with the web It allows you to send and receive messages to and from anyone with an

Syslog logging: enabled (11 messages dropped, 1 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled) Console logging: level debugging, 46

This new generational scheduling tool outperforms the traditional project timelines by visualising interdependencies among sub-systems (see Figure 1), articulating the boundary

This form required when determining whether commercial messages are going about political ad which forms or other requirements may otherwise expire under oath.. The required to