Upload
frank-wienberg
View
6.750
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Slides complementing our paper on the PLASTIC workshop of SPLASH 2011: http://plastic.host.adobe.com/
Citation preview
www.coremedia.com © CoreMedia | 24/10/11 | 1
Using ActionScript 3 for JavaScript ”Programming in the Large” Andreas Gawecki Frank Wienberg Software Architects & Jangaroo Evangelists
Enterprise JavaScript with Jangaroo
www.coremedia.com © CoreMedia | 24/10/11 | 2
Applications are supposed to run on many platforms. The browser is becoming the ubiquitous client platform, so everybody is doing JavaScript today.
Need
www.coremedia.com © CoreMedia | 24/10/11 | 3
The target platform Web / browser only understands JavaScript, but:
JavaScript was not made for programming in the large
Problem
www.coremedia.com © CoreMedia | 24/10/11 | 4
What Brendan says
"The over-minimized design of JS [...] imposed a long-term complexity tax on JS programmers and libraries. Everyone invents an OOP framework, some standard packaging discipline, and a latent type system. Why should not the core language address these obvious requirements?"
Brendan Eich, creator of JavaScript, 2008
www.coremedia.com © CoreMedia | 24/10/11 | 5
No packages / namespaces, classes, modules
No explicit interfaces / APIs
No static typing
Libraries and build process not standardized
JavaScript for Enterprise – The Bad Parts
www.coremedia.com © CoreMedia | 24/10/11 | 6
To target JavaScript, use a language similar to JavaScript, overcoming these Bad Parts:
ActionScript 3
Jangaroo Answer:
www.coremedia.com © CoreMedia | 24/10/11 | 7
But ActionScript already runs in the browser?!
www.coremedia.com © CoreMedia | 24/10/11 | 8
Yes, but only through a browser plugin!
www.coremedia.com © CoreMedia | 24/10/11 | 9
Some platforms not Flash-enabled (iOS)
FlashPlayer has to rely on quirky old Browser plugin API
Does not integrate seamlessly with (D)HTML
Up-to-date plugin version not installed everywhere
Feature set
Security
FlashPlayer Browser Plugin Downsides
www.coremedia.com © CoreMedia | 24/10/11 | 10
How to execute another programming language in the browser?
www.coremedia.com © CoreMedia | 24/10/11 | 11
Translate to JavaScript
by plugin
How to execute another programming language in the browser?
Interpret in JavaScript
www.coremedia.com © CoreMedia | 24/10/11 | 12
Which programming language?
www.coremedia.com © CoreMedia | 24/10/11 | 13
Which programming language?
ActionScript 3
(Adobe)
Java
(Oracle)
C#
(Microsoft)
www.coremedia.com © CoreMedia | 24/10/11 | 14
Available Technologies
by plugin Interpret
in JavaScript translate to JavaScript
Java Java Applet Orto GWT
C# Silverlight - / - Script
ActionScript Flash Player Swiffy (AS2) Jangaroo (AS3)
www.coremedia.com © CoreMedia | 24/10/11 | 15
ActionScript adds programming-in-the-large features missing in JavaScript
ActionScript and JavaScript are quite similar
Advantages of JavaScript are kept
Enhanced tool support
ActionScript 3 from a JavaScript developer’s point of view
www.coremedia.com © CoreMedia | 24/10/11 | 16
Jangaroo = Enterprise JavaScript ⊂ ActionScript 3
www.coremedia.com © CoreMedia | 24/10/11 | 17
Enterprise JavaScript with Jangaroo
Language and Compiler
Jangaroo Project
Software Development Lifecycle
Libraries and Applications
www.coremedia.com © CoreMedia | 24/10/11 | 18
Only supported syntactically
visibility modifiers (protected, internal)
namespace
typing (no type conversion / coercion)
Not (yet) supported
E4X (XML literals and -API)
Not supported in IE < 9
Property accessor functions (get / set)
Supported Features
package
class
private members
static members
inheritance (extends)
import
interface (implements)
helper classes (same file)
optional semicolons
annotation ([…])
Jangaroo’s ActionScript 3
www.coremedia.com © CoreMedia | 24/10/11 | 19
Compile ActionScript 3 to JavaScript that (through a
small runtime library)
a) runs in any browser and
b) looks very similar to the AS3 source code.
Jangaroo at Runtime
www.coremedia.com © CoreMedia | 24/10/11 | 20
Jangaroo Source Code
package joo.util {
public class Offset {
public static const HOME : joo.util.Offset = new Offset(0, 0);
public function Offset(left : Number , top : Number ) {
this.left = left;
this.top = top;
}
public function clone() : joo.util.Offset {
return new Offset(this.left, this.top);
}
public function getDistance() : Number {
return Math.sqrt(this.left*this.left + this.top*this.top);
}
public function scale(factor : Number) : joo.util.Offset {
return new Offset(this.left * factor, this.top * factor);
}
public function isHome() : Boolean {
return this.left==0 && this.top==0;
}
public var left : Number;
public var top : Number;
}}
www.coremedia.com © CoreMedia | 24/10/11 | 21
Jangaroo Compiled Code (JavaScript)
joo.classLoader.prepare(
"package joo.util",
"public class Offset",function($$l,$$private){var is=joo.is,assert=joo.assert,…;return[
"public static",{/*const*/ HOME/*: joo.util.Offset*/: function(){return new Offset(0, 0);}},
"public",function Offset(left/*: Number*/, top/*: Number*/) {
this.left = left;
this.top = top;
},
"public",function clone()/*: joo.util.Offset*/{
return new Offset(this.left, this.top);
},
"public",function getDistance()/*: Number*/{
return Math.sqrt(this.left*this.left + this.top*this.top);
},
"public",function scale(factor/*: Number*/)/*: joo.util.Offset*/{
return new Offset(this.left * factor, this.top * factor);
},
"public",function isHome()/*: Boolean*/{
return this.left==0 && this.top==0;
},
"public",{/*var*/ left /*: Number*/: undefined},
"public",{/*var*/ top /*: Number*/: undefined}
]});
www.coremedia.com © CoreMedia | 24/10/11 | 22
Jangaroo is More Than a Compiler
www.coremedia.com © CoreMedia | 24/10/11 | 23
2004: Start as internal project „JSC“
Using it in CoreMedia
CMS
07/2008: Open
Source „Jangaroo“
6/2009: From ECMAScript 4
to ActionScript 3
09/2010: github
10/2011: current version:
0.8.7
Jangaroo: Project History
http://blog.jangaroo.net/2008/07/former-life-and-birth-of-jangaroo.html
www.coremedia.com © CoreMedia | 24/10/11 | 24
Jangaroo Features
Class Initialization
Automatic Class Loading
Integrate with
JavaScript / HTML / browser
Modular Build Process (Maven)
Versioned Modules
Dependency Management
Source-level debugging IDE Support
Minimal Overhead
CI Integration
Unit Testing
Localization
www.coremedia.com © CoreMedia | 24/10/11 | 25
Software Lifecycle with Jangaroo
Jangaroo supports the whole lifecycle of professional software development of enterprise JavaScript applications
www.coremedia.com © CoreMedia | 24/10/11 | 26
Software Lifecycle with Jangaroo
IDE
Build Process
Unit Test Framework
Automatic UI Tests
Continuous Integration
HTML Documentation
Source-Level Debugging
www.coremedia.com © CoreMedia | 24/10/11 | 27
IntelliJ IDEA
Flash Develop
Flash Builder
Powerflasher FDT
IDE Support
www.coremedia.com © CoreMedia | 24/10/11 | 28
Command Line
Ant
Maven
IDEA (incremental)
Build Process
www.coremedia.com © CoreMedia | 24/10/11 | 29
UI Tests: Selenium
Continuous Integration: Hudson / Jenkins
Unit Tests: JooUnit = FlexUnit 0.9 Jangaroo
Test Tools
www.coremedia.com © CoreMedia | 24/10/11 | 30
Documentation: ASDoc
Debugging: Firebug & Co
Documentation and Debugging
www.coremedia.com © CoreMedia | 24/10/11 | 31
Language and infrastructure, check, but what kind of applications can you build with Jangaroo?
www.coremedia.com © CoreMedia | 24/10/11 | 32
JavaScript libraries can be used as-is or through “fake” AS3 API
Available Jangaroo modules with AS3 API wrappers:
Browser DOM and BOM API
Ext Core
Ext JS 3
Sencha Touch (alpha)
soundmanager 2
swfobject
…
Jangaroo Libraries A: Reuse JavaScript Libraries
www.coremedia.com © CoreMedia | 24/10/11 | 33
Open Source ActionScript libraries can simply be recompiled:
FlexUnit
Box2D
Flixel
Open Flash Chart
Flash standard libraries are
not Open Source and
there is no JavaScript implementation
thus have to be re-implemented in AS3 for Jangaroo: JooFlash
JooFlash is alpha / work in progress, available on github
Jangaroo Libraries B: Recompile ActionScript Libraries
www.coremedia.com © CoreMedia | 24/10/11 | 34
Localized
Extensible Scalable
„Enterprise UI“: CoreMedia Studio
www.coremedia.com © CoreMedia | 24/10/11 | 35
Ext JS is a nice JS UI framework, but
Defines yet another JavaScript class system
Misses declarative, typed UI language (nothing like Flex’ MXML)
Jangaroo Ext JS extensions:
Ext AS, an AS3 API for Ext JS
EXML, a typed XML language (XSD) to specify Ext JS UIs (compiled to AS3)
Typed resource bundles for localization
Ext AS / EXML for “Enterprise UIs”
CoreMedia Studio is completely written in AS3 / EXML
Ext AS / EXML example code and tutorial are publicly available https://github.com/CoreMedia/jangaroo-ext-as-examples
EXML
www.coremedia.com © CoreMedia | 24/10/11 | 36
User Group
http://groups.google.com/group/jangaroo-users/
Source Code
http://github.com/CoreMedia/jangaroo-tools
http://github.com/CoreMedia/jangaroo-libs
Ext AS / EXML Tutorial Code: https://github.com/CoreMedia/jangaroo-ext-as-examples
Demos
Flash Demos: http://www.jangaroo.net/files/examples/flash/lines/ http://www.jangaroo.net/files/examples/flash/box2d/
Browser Game: http://www.jangaron.net
Jangaroo: Resources
www.jangaroo.net
www.coremedia.com © CoreMedia | 24/10/11 | 37
Demos & Applications
www.coremedia.com © CoreMedia | 24/10/11 | 38
CONTENT | CONTEXT | CONVERSION
Singapore [email protected] tel +65.6562.8866
Hamburg [email protected] tel +49.40.32 55 87.0
San Francisco [email protected] tel +1.415.371.0400
London [email protected] tel +44.207.849.3317