Narrative Javascript

Narrative Javascript is an extension to Javascript that adds an operator to convert asynchronous operations into synchronous ones. It has a compiler that compiles the extended Javascript into normal Javascript.

It provides on the client side what continuation based web frameworks do on the server side. Instead of manually splitting up your code into callbacks and handlers for events, setTimeout, XMLHttpRequest callbacks, etc you write your code in a sequential manner.

The code is CPS transformed and the continuations at the point of use of the new operator are used for the callbacks - allowing continuation of the function when done.

It looks pretty nifty.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

It's time to become an

It's time to become an editor...

Sure thing. How do I go

Sure thing. How do I go about doing that?

You email me and signup...

You email me and signup... Quite an easy process actually :-)


Nice concept -- but did you look at the resultant code? Javascript has *real* closures! No need to fake them.

Using closures breaks line numbering

Using native closures would have been nice. My first attempts at building Narrative JavaScript tried to use native closures, but I soon discovered that's not possible while maintaining line numbering consistent with the original source code. In the end I decided that debuggability was the more important priority, hence I built in custom closure support. *shrug*