croczilla.com 
 home   stratified   bits&pieces   blog   personal   
  home > stratified js

Stratified JavaScript

A cross-browser extension to JavaScript providing advanced concurrency abstractions. It's implemented in JS itself; runs in unmodified IE, Firefox, Chrome, Safari. Does not require any native browser support.

Note: Stratified JavaScript has changed quite a bit in the past few months and much of the information below is now somewhat outdated. Please go to http://stratifiedjs.org for the current state of things.

For an overview of features, see this blog post.

How to use it

The easiest way to play around with SJS is to add the following include at the top of a html file:

<script type="text/javascript" src="sjs-loader.js"></script>

When the document has loaded, sjs-loader will look for any script tags with type="text/sjs", and compile & execute them.

sjs-loader also makes available some library code for Ajax programming.

Where to get it

You can grab a GPL-licensed prototype version based on Brendan Eich's Narcissus JS compiler here: sjs-loader.js v0.3.

SJS on client and server

A new version of SJS for use on both browser and server is currently being developed by Oni Labs. This version retains the spirit of the prototype implementation, but is rewritten from scratch with a new runtime engine, has slightly different semantics, and new concurrency constructs. It is scheduled to be released summer 2010. Here's a video with a demo of SJS on both server and client:

Implementation notes for v0.3 prototype

  • Testsuite here
  • JavaScript parity features missing from prototype 0.3:
    • break with label
    • void
    • for/in
    • throw/catch/finally
    • with
    • instanceof
    • delete
    • 'arguments' object
  • Known bugs:
    • 'this' pointer is wrong in suspend block
    • 'new' and 'new_with_args' only work with 'normal' JS constructors
    • ||, && need to eval args in sequence (see testsuite no. 5 and 6)
    • Some pathological switch/case/default constructs have wrong behaviour (see testsuite no. 25)
    • finally block can be executed before suspend block has finished executing. remainder of suspend block should be aborted in this case
    • Weird inner function scoping bug (see testsuite no. 32)