croczilla.com 
 home   stratified   oni   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.

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>

(You can grab the most recent version of the file sjs-loader.js here.)

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.

Implementation status

  • Prototype nearing completion.
  • Testsuite here
  • JavaScript parity features still to be implemented:
    • break with label
    • switch/case/default DONE
    • object literals DONE
    • array literals DONE
    • ?/: DONE
    • void
    • for/in
    • throw/catch/finally
    • with
    • new with args DONE
    • instanceof
    • typeof DONE
    • 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)
  • Stratified enhancements to be implemented:
    • |@| and &@& operators (parallel OR / parallel AND)
    • concurrent iteration feature
    • statement expressions
    • protected expressions