the decaffeinated robot - developing on android without java€¦the decaffeinated robot...

84
The Decaffeinated Robot Developing on Android without Java Daniel Solano Gómez Texas Linux Fest 2 April 2011 . . . . . .

Upload: truongkhuong

Post on 29-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

The Decaffeinated RobotDeveloping on Android without Java

Daniel Solano GómezTexas Linux Fest

2 April 2011

. . . . . .

OverviewIntroducing Android

Web applications

Cross-platform tools

Alternative JVM languages

Scripting Layer for Android

Native development tools

Demo

Conclusions

. . . . . .

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Introducing AndroidWhy Android?Android architectureDecaffeinating Android

Web applications

Cross-platform tools

Alternative JVM languages

Scripting Layer for Android

Native development tools

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Why choose Android?

Android is the pragmaticchoice for open sourcemobile development.

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Why choose Android?

Android is the pragmaticchoice for open sourcemobile development.

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Architectural overview

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Architectural overview

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Architectural overview

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Architectural overview

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Architectural overview

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

All apps run in a Dalvik VM

What does this mean?

In order to write apps for Android, youhave to do it within the Java-basedenvironment.

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

All apps run in a Dalvik VM

What does this mean?

In order to write apps for Android, youhave to do it within the Java-basedenvironment.

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

All apps run in a Dalvik VM

What if you do notwant to work withJava?

Good question.

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

All apps run in a Dalvik VM

What if you do notwant to work withJava?

Good question.

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroidWhy Android?Android architectureDecaffeinating Android

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Alternatives to Java

▶ Build a web app▶ Use a cross-platform developmenttool

▶ Use an alternative JVM language▶ Use the Scripting Layer for Android▶ Use the native development tools

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Introducing Android

Web applicationsCreating web appsChoosing to write a web app

Cross-platform tools

Alternative JVM languages

Scripting Layer for Android

Native development tools

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

What is it?

An web app is an application designedto run in a web browser using HTML,CSS, and Javascript.

▶ Can run in the browser▶ Can run in a browser widget

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

What is it?

An web app is an application designedto run in a web browser using HTML,CSS, and Javascript.

▶ Can run in the browser

▶ Can run in a browser widget

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

What is it?

An web app is an application designedto run in a web browser using HTML,CSS, and Javascript.

▶ Can run in the browser▶ Can run in a browser widget

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Leverage HTML5

▶ Cache for off-line use▶ Persistent web storage▶ Video▶ Geolocation

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Advantages

▶ Use familiar tools andtechnologies

▶ As close to truly cross-platform aspossible

▶ Instant updates for all users

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Disadvantages

▶ Performance▶ No deep integration with theplatform

▶ No market visibility▶ Not a ‘native experience’

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

WebapplicationsCreating web appsChoosing to write a webapp

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Resources

▶ Android-specific web app documentationat http://developer.android.com/guide/webapps/index.html

▶ Mobile Boilerplate, a ‘template forcreating rich and performant mobile webapps’, at http://html5boilerplate.com/mobile/

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtoolsPhoneGapAppcelerator TitaniumRhomobile RhodesChoosing to use across-platform tool

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Introducing Android

Web applications

Cross-platform toolsPhoneGapAppcelerator TitaniumRhomobile RhodesChoosing to use a cross-platform tool

Alternative JVM languages

Scripting Layer for Android

Native development tools

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtoolsPhoneGapAppcelerator TitaniumRhomobile RhodesChoosing to use across-platform tool

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

PhoneGaphttp://www.phonegap.com

▶ Creates packaged web apps▶ Allows development withJavaScript, HTML5, and CSS3

▶ Provides a JavaScript library toexpose platform APIs

▶ Builds packages for all majorplatforms

▶ MIT license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtoolsPhoneGapAppcelerator TitaniumRhomobile RhodesChoosing to use across-platform tool

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Appcelerator Titaniumhttp://www.appcelerator.com

▶ Provides a JavaScript library toexpose platform APIs

▶ Builds as a native app for Androidand iOS

▶ Interprets app logic at runtime▶ Apache license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtoolsPhoneGapAppcelerator TitaniumRhomobile RhodesChoosing to use across-platform tool

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Rhomobile Rhodeshttp://rhomobile.com

▶ Allows development in Ruby withan MVC-style framework

▶ Builds native apps for all majorplatforms

▶ Integrates with enterprise featuresfrom other Rhomobile products

▶ MIT license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtoolsPhoneGapAppcelerator TitaniumRhomobile RhodesChoosing to use across-platform tool

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Things to consider

▶ Is being dependent on the toolacceptable?

▶ What features does your appneed?

▶ What platforms do you need tosupport?

▶ How important is performance?▶ Is the license compatible with yourapp?

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Introducing Android

Web applications

Cross-platform tools

Alternative JVM languagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use an alternative JVM language

Scripting Layer for Android

Native development tools

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

The good news

Java ≠ JVM

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

The (somewhat) bad news

JVM ≠ Dalvik VM

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

The Dalvik VM and JVMlanguages

▶ Incompatible byte codes means nodynamic compilation (no Jython)

▶ Staticly compiled and interpretedlanguages still work

▶ Beware of resource limits

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Ruboto (JRuby)http://ruboto.org

▶ ruboto-irb

▶ Provides IRB console and runs scripts▶ Allows Android API exploration▶ Available from Android Market

▶ ruboto-core

▶ Provides a development frameworkfor Android apps

▶ Includes UI setup domain-specificlanguage

▶ Uses familiar Ruby tools▶ MIT license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Ruboto (JRuby)http://ruboto.org

▶ ruboto-irb▶ Provides IRB console and runs scripts▶ Allows Android API exploration▶ Available from Android Market

▶ ruboto-core

▶ Provides a development frameworkfor Android apps

▶ Includes UI setup domain-specificlanguage

▶ Uses familiar Ruby tools▶ MIT license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Ruboto (JRuby)http://ruboto.org

▶ ruboto-irb▶ Provides IRB console and runs scripts▶ Allows Android API exploration▶ Available from Android Market

▶ ruboto-core▶ Provides a development frameworkfor Android apps

▶ Includes UI setup domain-specificlanguage

▶ Uses familiar Ruby tools▶ MIT license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Hello, world!

require ’ ruboto . rb ’

ruboto_import_widgets :TextView

$activity . handle_create do |bundle |setup_content dotext_view : text => ”Hello , world !”

endend

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Ruboto impressions

▶ Starts slowly▶ Hogs memory▶ Some JRuby features don’t work▶ Weird redeploy cycle

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Mirahhttp://www.mirah.org

▶ Ruby-like syntax▶ No runtime library▶ No performance penalty▶ Metaprogrammming and macros▶ Apache license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Hello, world!

import android .app. Act iv ityimport android .widget . TextView

class HelloActivity < Activ itydef onCreate( state )super statetext = TextView .new sel ftext . setText ”Hello , world !”setContentView text

endend

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Mirah impressions

▶ Excellent performance▶ Using Pindah makes it easy to getstarted

▶ Approachable for Rubyprogrammers

▶ Young language, littledocumentation

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Scalahttp://www.scala-lang.org

▶ Combines functional andobject-oriented paradigms

▶ Concise syntax▶ Good type inference▶ Used by LinkedIn, Twitter,FourSquare

▶ BSD license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Hello, world!

import _root_ . android .app. Act iv ityimport _root_ . android . os .Bundleimport _root_ . android .widget . TextView

class GameChooserActivity extends Act iv ity {override def onCreate( savedInstanceState : Bundle) {super . onCreate( savedInstanceState )val text = new TextView( this )text . setText ( ”Hello , world !” )setContentView( text )

}}

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Scala impressions

▶ Using simple build tool (sbt) withAndroid plugin makesdevelopment a breeze

▶ Very good performance▶ Powerful▶ Approachable to Javaprogrammers

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Clojurehttp://www.clojure.org

▶ A Lisp for the JVM▶ Software transactional memoryand concurrency primitives

▶ Clojure REPL available on AndroidMarket

▶ Easy interop with Java▶ EPL license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Hello, world!

(ns HelloWorld( : gen−class :extends android .app. Act iv ity

:exposes−methods {onCreate superOnCreate})( : import android .widget . TextView ) )

(defn −onCreate[ this bundle](doto this( . superOnCreate bundle)( . setContentView (doto (TextView . this )

( . setText ”Hello , world !” ) ) ) ) )

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Clojure impressions

▶ Start-up can be slow▶ More memory-intensive than Java,Mirah, and Scala

▶ Upcoming leaner runtime shouldhelp address performance

▶ Neko library should help makeAndroid development faster andmore concise

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Kawahttp://www.gnu.org/software/kawa/

▶ Scheme implementation for theJVM

▶ Requires no runtime▶ Includes some Android supportbuilt-in

▶ MIT license

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Hello, world!

( require ’android−defs )

( act iv i ty HelloKawa(on−create−view(android .widget . TextView ( this )text : ”Hello , world !” ) ) )

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Kawa impressions

▶ Excellent performance▶ Relatively obscure, smallcommunity

▶ Not much tool support

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Advantages

▶ Gives you access to the full API▶ You can use familiar tools▶ Some languages perform as wellas Java

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguagesIntroductionRuboto (JRuby)MirahScalaClojureKawaChoosing to use analternative JVMlanguage

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Disadvantages

▶ Some languages have significantoverhead

▶ May run into interop corner cases▶ Tool support may be lacking forsome languages

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Introducing Android

Web applications

Cross-platform tools

Alternative JVM languages

Scripting Layer for AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Native development tools

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Scripting Layer for Androidhttps://code.google.com/p/android-scripting/

▶ Brings scripting languages toAndroid

▶ Loads, edits, and executes scripts▶ Provides interactive consoles▶ Provides access to many AndroidAPIs

▶ Runs interactively, in thebackground, or via Locale

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Supported languages

▶ Beanshell▶ JavaScript (Rhino)▶ JRuby▶ Lua▶ Python▶ Perl▶ PHP▶ Shell▶ Tcl

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

How SL4A works

SL4A ServiceContacts Preferences Phone

Wifi UI Location

Battery

Camera

Application

Perl

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

How SL4A works

SL4A ServiceContacts Preferences Phone

Wifi UI Location

Battery

Camera

Application

Rhino

Application

Python

Application

Perl

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

How SL4A works

SL4A ServiceContacts Preferences Phone

Wifi UI Location

Battery

Camera

Application

Rhino

Application

Python

Application

Perl

JSON RPC

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

SL4A limitations

▶ Generally, access to API isrestricted to exposed façades

▶ Languages that can invoke Javadirectly can access full API

▶ Designed for ease of use, notperformance

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Writing scripts

▶ Use an interactive terminal andsave or e-mail the results

▶ Use a built-in editor to createscripts

▶ Run a server to develop scriptsover a network or USB

▶ Package script as an app, but stillrequires separate interpreterinstallation

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Advantages

▶ Interactive development from acomputer is quick and easy

▶ Ideal for scripting a device▶ Use a wide variety of languages

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor AndroidIntroductionDeveloping with SL4AChoosing to use SL4A

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Disadvantages

▶ Not ideal for writing applications:▶ Multistep installation▶ Limited UI options (dialogs andHTML)

▶ Cannot access full platform APIs▶ Performance may not be optimal

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Introducing Android

Web applications

Cross-platform tools

Alternative JVM languages

Scripting Layer for Android

Native development toolsIntroductionDeveloping with the NDKChoosing to use the NDK

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

What is it?

▶ Designed to allow you to writeperformance-critical code in C/C++

▶ Supplements the SDK▶ Still runs in the Dalvik VM

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Where it fits

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Building with the NDK

▶ NDK provides:▶ Cross-compiler▶ System libraries and headers▶ Build tools▶ Debugger

▶ NDK creates shared libraries to beincluded in an app

▶ Still use SDK to build packages

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Using JNIThe Java part

public class Hel loJni extends Act iv ity {public native String stringFromJNI ( ) ;

stat ic {System. loadLibrary (”hello−j n i ” ) ;

}}

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Using JNIThe C part

#include<string .h>#include<jn i .h>

jst r ingJava_com_example_hellojni_HelloJni_stringFromJNI (JNIEnv* env, jobject thiz )

{return (*env)−>NewStringUTF(env, ”Hello , from JNI !” ) ;

}

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Using JNIThe Makefile (Android.mk)

LOCAL_PATH := $( ca l l my−dir )

include $(CLEAR_VARS)

LOCAL_MODULE := hello−j n iLOCAL_SRC_FILES := hello−j n i . c

include $(BUILD_SHARED_LIBRARY)

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Native activities

▶ As of Gingerbread (2.3), it ispossible to make 100% nativeactivities

▶ Interface with the NDK eitherthrough callbacks or an event loop

▶ UI restricted to OpenGL

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

NativedevelopmenttoolsIntroductionDeveloping with theNDKChoosing to use the NDK

Demo

Conclusions

. . . . . .

Use cases

▶ Performance critical code▶ Using an existing library▶ Embed an interpreter (Lua andGambit Scheme have been done)

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

Introducing Android

Web applications

Cross-platform tools

Alternative JVM languages

Scripting Layer for Android

Native development tools

DemoThe DemoComparisons

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

About the demo▶ Guess the number with aWarGames twist

▶ Code available from GitHub:https://github.com/sattvik/decafbot

▶ Implementations in:▶ Ruboto▶ Mirah▶ Scala▶ Clojure▶ Java with JNI▶ Python with SL4A

▶ Not necessarily the absolute bestimplementations

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

Package size

1. Python size does not include interpreter

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

Installed size

1. Python size does not include interpreter

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

Startup time

1. Ruboto measurement is approximate

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

Heap use

1. Native portions of Python and JNI are not reported

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

DemoThe DemoComparisons

Conclusions

. . . . . .

Lines of code

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Introducing Android

Web applications

Cross-platform tools

Alternative JVM languages

Scripting Layer for Android

Native development tools

Demo

Conclusions

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Is Android without Javapossible?

Yes!

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Is Android without Javapossible?

Yes!

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Recommendations

▶ Mature technologies that haveworked well for me or others:

▶ Web apps▶ Cross-platform development tools▶ Scala▶ Native development tools

▶ Technolgies that should run well,but for which development maybe trickier:

▶ Mirah▶ Kawa

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Recommendations

▶ Technologies that show promise,but aren’t entirely ready yet:

▶ Clojure▶ Ruboto

▶ Technologies that serve a niche:▶ Scripting layer for Android

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Non-free alternatives

▶ MonoDroid▶ Adobe AIR

TheDecaffeinated

Robot

Daniel SolanoGómez

IntroducingAndroid

Webapplications

Cross-platformtools

Alternative JVMlanguages

Scripting Layerfor Android

Nativedevelopmenttools

Demo

Conclusions

. . . . . .

Thank you!Blog www.deepbluelambda.org

Twitter @deepbluelambdaE-mail [email protected]