Yet Another DSL for Cross-platforms Mobile Development

Size: px
Start display at page:

Download "Yet Another DSL for Cross-platforms Mobile Development"

Transcription

1 Yet Another DSL for Cross-platforms Mobile Development GlobalDSL 2013 # Sessi 2 Mtpellier, 2013 Olivier Le Goaer and Sacha Waltham olivier.legoaer@univ-pau.fr

2 Agenda Ctext of work A survey of existing tools Presentati of the soluti Questis?

3 Ctext of work

4 Development shift The new era of mobility People msively use apps handheld devices (SmartPhes, Tablets) From Desktop applicati to mobile applicatis Lower ressources (battery, network latency, processor, etc.) Smaller and new navigati fhi ( Tap-able not clickable ) Increed platform heterogeneity Now steady, limited number of desktop OS Yet unsteady, high number of mobile OS

5 Heterogeneity is back! «Desktop App» Development «Mobile App» Development $$ $$$$$, augmented Time-to-Market

6 Mobile app: native or web? Two development approaches are competing Native: develop directly for the mobile device Web: develop for a browser installed in the mobile device, and tailored to be «mobile-friendly» Tame the development costs... Native: e app per platform Web: solely e app (suming that nowadays the different browsers evenly process the code)...but not neglect the «user experience» Native: almost limitless capabilities Web: limited to the browser capabilities

7 In a nutshell WebApps are the best way to reach the most possible people with the let effort WebApps are inherently cross-platforms but in the agnostic sense (the underlying OS specificities are ignored) The browser already partly solved the heterogeneity questi NativeApps are the best way to create the best possible experience Native apps are specifically designed for their host, and hence require further solutis to achieve actual cross-platform Cross-platform Mobile development Tools (XMTs) have emerged This is where the scientific challenge lies

8 A survey of existing tools

9 Write Once? Run everywhere? Bridge Translati HTML5,CSS3, JavaScript C++, Java, Ruby,

10 Reappearance of MDA Such heterogeneity and lack of sustainability w already encountered in the pt The mid-2000s w the age of «middlewar» The OMG brought its Model-Driven Architecture (MDA) visi When MDA meets the mobile challenge Capture knowledge into models Describe things independently of mobile platforms (PIM level) Platform details are woven subsequently (PSM level) OMG's ctributis (UML2, MOF, QVT) are centre-stage, but main-specific languages are encouraged A langage dedicated to the mobile main rather than a general-purpose language Offers a bis for further stuff (tests, simulati and analysis,...)

11 Overview of existing XMTs

12 Ratiales of the soluti Domain-specific language Define a language which really fits your needs Decree the efforts needed to write a (simple) mob app Obviously far away to be complete a general language Key idea : «Write less, generate more» Generati of full-native code Because this is the holy grail of mobile programming Model-driven Architecture Proved that «it works». Separati PIM/PSM is useful. Reinventing the wheel? Several languages may be competing. Let us try...

13 Presentati of the soluti

14 roadmap Set the architecture of the crosscompiler Envisi a MDA-compliant chain to produce native code Design the language Define both its abstract and ccrete syntax Create UML profiles for each platform Write the sociated transformati (M2M and M2T) Android initially, then move to other platforms Deliver the soluti an Eclipse Plugin Built top of EMF But the generated code ought to be reworked into specific IDE

15 Cross-compiler Architecture PIM Xmob crosscompiler PSM UML2 + ios Profile M2T M2M PSM UML2 + Android Profile M2T M2M M2M PSM UML2 + WP8 Profile M2T Native Code Objective-C program Native Code Java program Native Code.NET program

16 sub-languages Deals with display (widgets) -UI MOB-UI Deals with gluing together UI and data -event MOB-event -data MOB-data Deals with data sources (read ly)

17 Mobile-specific shared ccepts -UI UI is broken wn into a successi of s UI elements (widgets) are declared inside a UI elements will automatically be placed the -data Datources locati: local or remote Datources format: xml, js, recordset, raw text,... -event Triggers actis System-related or UI-related events Actis are bed verbs : open, close, fetch, start,...

18 abstract syntax (Ecore)

19 ccrete syntax (Xtext) h a textual syntax Better suited than graphical syntax, especially for data and events h multiple files Separated ui/event/data files but same extensi «.xmob» Implies to manage properly cross-references and scoping No Type System nor Functi definiti Because is much more a descripti language than a programming language Because this is a tedious tk: code for type-checking and calls must be added programmatically to the parser

20 EMF Tooling for the soluti OS-specific Source code project file *.xmob UML2Code Template Xpand emitter ANTLR parser Xtext Generator grammar uml2adt.xpand uml2x-code.xpand... uml2.ecore UML metamodel Kermeta engine metamodel xmob.ecore xmob.xtext UML model + profile model (in-memory) 2UML Transform. xmob2android.kmt xmob2ios.kmt...

21 snippets main main l_welcome l_welcome label["welcome label["welcome to to this this app"] app"] b_next b_next butt["proceed butt["proceed to to next next "] "] menu menu item[image: item[image: "settings.png", "settings.png", destinati:settings] destinati:settings] item[text:"credits", item[text:"credits", destinati:credits] destinati:credits] next next label["here label["here is is some some data:"] data:"] list_somedata list_somedata list list credits credits label["ctributors:"] label["ctributors:"] label["olivier label["olivier le le Goaer Goaer & & Sacha Sacha Waltham"] Waltham"] settings settings label["music label["music?"]?"] switch_music switch_music switch switch #xmob-data #xmob-data somedata somedata datource datource remote remote [" [" return return [xml] [xml] #xmob-event #xmob-event (pressed[main.b_next]) (pressed[main.b_next]) open[next] open[next] (networkavailable[system]) (networkavailable[system]) fetch[somedata] fetch[somedata] into[next.list_somedata] into[next.list_somedata] (switched[settings.switch_music]) (switched[settings.switch_music]) start[player:./music.mp3] start[player:./music.mp3]

22 snippets main main l_welcome l_welcome label["welcome label["welcome to to this this app"] app"] b_next b_next butt["proceed butt["proceed to to next next "] "] menu menu item[image: item[image: "settings.png", "settings.png", destinati:settings] destinati:settings] item[text:"credits", item[text:"credits", destinati:credits] destinati:credits] #xmob-data #xmob-data somedata somedata datource datource remote remote [" [" return return [xml] [xml] next next label["here label["here is is some some data:"] data:"] list_somedata list_somedata list list credits credits label["ctributors:"] label["ctributors:"] label["olivier label["olivier le le Goaer Goaer & & Sacha Sacha Waltham"] Waltham"] settings settings label["music label["music?"]?"] switch_music switch_music switch switch #xmob-event #xmob-event (pressed[main.b_next]) (pressed[main.b_next]) open[next] open[next] (networkavailable[system]) (networkavailable[system]) fetch[somedata] fetch[somedata] into[next.list_somedata] into[next.list_somedata] (switched[settings.switch_music]) (switched[settings.switch_music]) start[player:./music.mp3] start[player:./music.mp3] Android BroadctReceiver AsyncTk Progress Dialog SAX Parser ArrayAdapter...

23 Questis?