AmbientTalk:
         A scripting language
         for Android devices
         Dries Harnie




Tuesday 25 January 2011

Hello everyone, my name is Dries Harnie and I’m here to present AmbientTalk: a scripting
language for android devices.
The AmbientTalk Team


                  Wolfgang De Meuter        Tom Van Cutsem       Stijn Mostinckx Elisa Gonzalez Boix Dries Harnie




                          Andoni Lombide Christophe Scholliers    Eline Phillips     Kevin Pinte     Lode Hoste




Tuesday 25 January 2011

We are AmbientTalk. Resistance is futile.
Look for us with the ambientTalk tshirts
Motivation

Tuesday 25 January 2011

As discussed by the panel.
“Put everything in the cloud”
         What is wrong with this picture?

Tuesday 25 January 2011

cloud printing.
Who here has ever printed when he was not in walking range of a printer?
You want to walk up to a printer and say “print this”, not find it in a cloud and then print to it
over a slow connection.
A very cool cloud app.

Tuesday 25 January 2011

This is a service I joined recently.
They allow you to store files in the cloud.
However, they do things differently.
If you have two devices on the same network, they will communicate directly, saving
bandwidth.
This is something we should embrace in ALL applications: why go via the cloud if you can do
it directly?
Goal




Tuesday 25 January 2011

We want to write an app that allows people to collaborate on some task (ie. painting).
AmbientTalk
         - Asynchronous
         - Peer to peer




Tuesday 25 January 2011

AmbientTalk!
Language designed to be robust against disconnections
Async. communication
         Buffer when other side is down

Tuesday 25 January 2011
Discovery
         “Sniffing around”
         for other devices




Tuesday 25 January 2011
Deployment on real devices




Tuesday 25 January 2011

Because we wrote the AT interpreter in Java it runs unmodified on all desktop platforms.
We managed to squeeze it onto HTC Touch Cruise phones running the IBM J9 VM, but we ran
into all sorts of issues.
iPhone .. no real java support
Finally android, but not without issues.
Portability
         issues:           ✉
                               ✓

         Multicast             ✓
         - Works in 1.0
         - Broken in 1.5
                               ✗
         - Fixed in 1.6




Tuesday 25 January 2011
Portability issues:
         memory

              AmbientTalk parser uses a lot of stack space




              Many threads ... ++ungood.




Tuesday 25 January 2011
Portability issues:
         serialization
              ClassCastException: serialVersionUid doesn’t match
              Three different classloaders
               A) ClassLoader.getSystemClassLoader()

               B) Thread.setContextClassLoader()
               C) Foo.class.getClassLoader()
                  # This is the only one that knows about your classes.




Tuesday 25 January 2011

When transferring objects from/to android, make sure the serialVersionUid fields match.
These are usually computed, but dalvik and sun jvms do it differently.
The proof of the pudding...


                          http://youtu.be/k0HYqRCxtHc




Tuesday 25 January 2011

this is a demo we made yesterday.
I wrote the app in four hours.
~ 90 lines of ambienttalk, of which only 20 networking.
400 lines of java. mostly stolen from api demo.
import /.demo.weScribble
   deftype Painter;                             def remoteInterface := object: {
                                                	   def touchStart(other, x, y, color) {
   def otherPainters := [];                     	   	   ... drawing stuff ...
                                                	   };
   whenever: Painter discovered: { |ref|        	   def touchEnd(other, x, y) {
   	  Android.Log.v("Fingerpaint",              	   	   ... drawing stuff ...
         "Discovered other painter:" + ref);    	   };
   	  otherPainters := otherPainters + [ref];   	   def erase() {
   };                                           	   	   ... drawing stuff ...
                                                	   };
   network.online;                              };

                                                export: remoteInterface as: Painter;




Tuesday 25 January 2011

I’ll even show you the code!
Look, an import statement ;)
Conclusion
                                                 @ambienttalk




                          http://ambienttalk.googlecode.com
Tuesday 25 January 2011

AmbientTalk, a scripting language for Android devices - Dries Harnie, VUB - droidcon.be 2011

  • 1.
    AmbientTalk: A scripting language for Android devices Dries Harnie Tuesday 25 January 2011 Hello everyone, my name is Dries Harnie and I’m here to present AmbientTalk: a scripting language for android devices.
  • 2.
    The AmbientTalk Team Wolfgang De Meuter Tom Van Cutsem Stijn Mostinckx Elisa Gonzalez Boix Dries Harnie Andoni Lombide Christophe Scholliers Eline Phillips Kevin Pinte Lode Hoste Tuesday 25 January 2011 We are AmbientTalk. Resistance is futile. Look for us with the ambientTalk tshirts
  • 3.
    Motivation Tuesday 25 January2011 As discussed by the panel.
  • 4.
    “Put everything inthe cloud” What is wrong with this picture? Tuesday 25 January 2011 cloud printing. Who here has ever printed when he was not in walking range of a printer? You want to walk up to a printer and say “print this”, not find it in a cloud and then print to it over a slow connection.
  • 5.
    A very coolcloud app. Tuesday 25 January 2011 This is a service I joined recently. They allow you to store files in the cloud. However, they do things differently. If you have two devices on the same network, they will communicate directly, saving bandwidth. This is something we should embrace in ALL applications: why go via the cloud if you can do it directly?
  • 6.
    Goal Tuesday 25 January2011 We want to write an app that allows people to collaborate on some task (ie. painting).
  • 7.
    AmbientTalk - Asynchronous - Peer to peer Tuesday 25 January 2011 AmbientTalk! Language designed to be robust against disconnections
  • 8.
    Async. communication Buffer when other side is down Tuesday 25 January 2011
  • 9.
    Discovery “Sniffing around” for other devices Tuesday 25 January 2011
  • 10.
    Deployment on realdevices Tuesday 25 January 2011 Because we wrote the AT interpreter in Java it runs unmodified on all desktop platforms. We managed to squeeze it onto HTC Touch Cruise phones running the IBM J9 VM, but we ran into all sorts of issues. iPhone .. no real java support Finally android, but not without issues.
  • 11.
    Portability issues: ✉ ✓ Multicast ✓ - Works in 1.0 - Broken in 1.5 ✗ - Fixed in 1.6 Tuesday 25 January 2011
  • 12.
    Portability issues: memory AmbientTalk parser uses a lot of stack space Many threads ... ++ungood. Tuesday 25 January 2011
  • 13.
    Portability issues: serialization ClassCastException: serialVersionUid doesn’t match Three different classloaders A) ClassLoader.getSystemClassLoader() B) Thread.setContextClassLoader() C) Foo.class.getClassLoader() # This is the only one that knows about your classes. Tuesday 25 January 2011 When transferring objects from/to android, make sure the serialVersionUid fields match. These are usually computed, but dalvik and sun jvms do it differently.
  • 14.
    The proof ofthe pudding... http://youtu.be/k0HYqRCxtHc Tuesday 25 January 2011 this is a demo we made yesterday. I wrote the app in four hours. ~ 90 lines of ambienttalk, of which only 20 networking. 400 lines of java. mostly stolen from api demo.
  • 15.
    import /.demo.weScribble deftype Painter; def remoteInterface := object: { def touchStart(other, x, y, color) { def otherPainters := []; ... drawing stuff ... }; whenever: Painter discovered: { |ref| def touchEnd(other, x, y) { Android.Log.v("Fingerpaint", ... drawing stuff ... "Discovered other painter:" + ref); }; otherPainters := otherPainters + [ref]; def erase() { }; ... drawing stuff ... }; network.online; }; export: remoteInterface as: Painter; Tuesday 25 January 2011 I’ll even show you the code! Look, an import statement ;)
  • 16.
    Conclusion @ambienttalk http://ambienttalk.googlecode.com Tuesday 25 January 2011