JavaScript and OSGi

bootlessbwakInternet και Εφαρμογές Web

12 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

104 εμφανίσεις

JavaScript and OSGi




Simon Kaegi, Orion Project Co
-
lead

IBM Canada @skaegi

2


What’s up with JavaScript
…and why OSGi now?


3


2005


Open Source AJAX Libraries


Firefox and Webkit


2008


Google Chrome and … V8!


WHATWG and HTML5


EcmaScript 5 (nee 3.1)


2009


Node.js

4

JavaScript 2013…


Aging AJAX Frameworks


Limited framework inter
-
op


Cottage industry of micro libraries


NPM Package Hell


(Tools are still horrible)


…victim of its own success


5


JavaScript is going through growing pains
similar to what Java experienced ten years
ago.



OSGi concepts and experiences are universal
and relevant to JavaScript.

6


“OSGI seems like
overengineered

Java stuff.

I'm
generally pretty skeptical of
big

frameworks that do
everything for everyone.

Usually they're a
big

pain
.”


-
Isaac Schlueter (emphasis is mine)


7

OSGi for JavaScript


OSGi


Focused, Lightweight, Open

Core JavaScript Problem Areas


Modularity


CommonJS “require”


AMD (Browser)


require(stringID, callback)


async


Node (Server)


require(stringID)


sync



ES6 Module Loader


http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders



Closer to class
-
loading than bundle loading



Core JavaScript Problem Areas


Packages


NPM Packages








Closest thing to a bundle but more just project metadata



OSGi bundles can be NPM Packages and vice
-
versa


Useful work to be done right now!




Core JavaScript Problem Areas


Asynchronous API


Registered Callback Pattern (Node)


doService(params, callback)



Promises “A+”


doService(params).then(onSuccess, onFailure)


http://promises
-
aplus.github.com/promises
-
spec/


W3C DomFutures



ES6 Generators / Co
-
routines


http://wiki.ecmascript.org/doku.php?id=harmony:generators



Core JavaScript Problem Areas


Extensibility and Services


OpenAjax / OpenSocial


Web Intents (W3C Webapps WG)



No strong standards plays at the moment


Go OSGi!



Orion and OSGi


Micro

Services


Complete implementation of OSGi Services API


Uses Promises for return types to decouple from async service
implementation details


Data only / No transferable functions



PluginRegistry


OSGi Lifecycle and Bundle State semantics used for Plugins


OSGi Framework startup



Preferences/Settings


Implementation of Configuration Admin and Metatype for Plugin
Settings and Schema


Orion Core Retrospective


Orion core “strongly” OSGi influenced


Very small, fast, stable and predictable


Nearly all OSGi service specifications in the compendium
are applicable in JavaScript.



Direct Service API use has poor usability characteristics



We need to find a simpler usage pattern to make OSGi
Services more approachable to the JavaScript community.



Closing Thoughts


JavaScript is an increasingly reasonable choice as a systems
language


Tons of innovation and tons of growing pains



OSGi can really be of help here however


We need to correct some invalid perceptions


We need to make our APIs easier to use and adopt