javascript for vw applications
DESCRIPTION
Title: JavaScript for VW Applications Speaker: Holger Kleinsorgen & Jan Schümmer Wed, August 20, 11:45am – 12:30pm Video Part1: https://www.youtube.com/watch?v=ZGAMCz62OM0 Video Part2: https://www.youtube.com/watch?v=cUk4C3c5gG4 Video Part3: https://www.youtube.com/watch?v=Mt1kVFSEQG8 Description Complex applications benefit from a built-in scripting language that is easy to use and commonly understood. Smalltalk is a cool language for us, but in some cases and for the broad public, JavaScript is more suitable. Up to now there was no JavaScript implementation available for Smalltalk that covers the full JavaScript ECMA 5 standard and shows production quality. In our talk we will present features and implementation details of our JavaScript engine and show how we integrated it into the latest version of our product “k-infinity”. As the engine is available under MIT license in the Cincom public repository, we invite everyone to use it in their own applications. Bio: Holger Kleinsorgen and Jan Schümmer are looking back at more than twenty years of Smalltalk development. They are part of the COAST team (c.f. ESUG 2000), and together with their colleagues at intelligent views they are developing the semantic database k-infinity (c.f. ESUG 2001 and 2002).TRANSCRIPT
JavaScript for VW Applica1ons
JavaScript for VW Applica1ons Holger Kleinsorgen & Jan Schümmer intelligent views, Darmstadt, Germany ESUG 2014 – Cambridge, UK
JavaScript for VW Applica1ons
K-‐Infinity -‐ our core product
2
• semanJc database
• modelling
• querying
• data integraJon
• web frontend (Java)
• REST services
• highly configurable
à need for scrip1ng throughout the system
JavaScript for VW Applica1ons
3
Smalltalk sandbox
J J K J J
JavaScript
JJ J JJ J J
First try: KScript
easy to communicate L easy to learn L universal / wide spread LL suitable K flexible L
JavaScript for VW Applica1ons
Anything reusable out there?
4
only one dead ST implementaJon
3rd party C libraries
• Jed to web environments
• uncertain future
Mozilla Rhino
• Java implementaJon would need JNI
• lack of flexibility for host object integraJon
We wanted real Smalltalk Objects without addiJonal runJmes
JavaScript for VW Applica1ons
5
What is important?
• conform to the specs
• easy to integrate host objects
• maintainable
What is not that important
• performance
à simply follow the 250 pages of the ECMA 5 spec
JavaScript for VW Applica1ons
Parser
6
• PeJtParser • PEG + Memoizing + Stuff, Smalltalk notaJon
• Tweaked for more precise error locaJons
• separated into lexical and syntacJcal part • follows structure of ECMA spec
• adapted for PEG (no lec recursions, alternaJves parse first match)
• quirks due to spec • strict mode
• disJnguish regex literals from expressions
• automaJc semicolon inserJon
JavaScript for VW Applica1ons
Parser
7
JavaScript for VW Applica1ons
RunJme
8
• Everything represented by dedicated objects • JSEAbstractObject (Javascript objects and primiJves)
• JSEExecuJonEnvironment + JSEExecuJonContext
• JSEBinding, JSEReference, JSEProperty
• Implement algorithms of the spec
• VW VM garbage collecJon
• Language core implemented by JSERunJmeImplementaJon
• Syntax tree transformed to code blocks
• Code blocks are evaluated in an execuJon context • Interpreted and thus quite slow
JavaScript for VW Applica1ons
9
ECMAScript Language Specifica1on 5.1, page 76
JavaScript for VW Applica1ons
ECMA conformance test suite
10
• about 11500 unit tests
• current result: 313 failures, 95 errors (4 %)
• browsers: between 8 and 52 failures / errors (0.06 % – 0.45 %)
• test cases helped to find the nicy / exoJc parts
• decided to accept some failures for the Jme being
JavaScript for VW Applica1ons
11
Demo 1me
JavaScript for VW Applica1ons
K-‐Infinity IntegraJon
12
Usage Example • definiJon of a REST
service
SemanJc Net API
Debugger
JavaScript for VW Applica1ons
Ups and Downs
13
The good parts
• (mostly) works as expected
• implementaJon was straight forward
• use cool JS libraries
• fast enough for our use cases
The cheesy parts
• parser hacks
• the "usual" browser objects are not available
• took some Jme
JavaScript for VW Applica1ons
Wish list
14
• switch to single grammar
• switch to VW PEG Parser • nicer to read due to DSL, easier to maintain
• already includes JS grammar, needs some tweaks though
• byte code compiler • only as a pet project, not required currently
• all test cases pass
• ECMA 6 (especially collecJons)
JavaScript for VW Applica1ons
15
JavascriptEngine-‐Bundle MIT License
Public Repository
{h.kleinsorgen|j.schuemmer}@i-‐views.de
Thank you for your aRen1on