Scores of languages now compile to JavaScript, which allows programmers to use many languages on the Web. Unfortunately, most compilers simply inherit the browser's execution model: long-running programs freeze the browser tab, blocking operations do not work, deeply recursive programs quickly overflow the stack, infinite loops crash Web-based IDEs, and so on. Stopify is a JavaScript-to-JavaScript compiler that is designed to help compiler authors address these limitations easily and efficiently.
There are four key pieces to Stopify.
See the question above: it depends on the source language and the sub-language of JavaScript that the source language compiler uses. We have extensive benchmarks that we can share if you're interested. But, to give an example, on Python (using PyJS), we find that the median slowdown is 1.4x. PyJS doesn't use all of JavaScript's features and we can exploit that to improve performance. Our worst slowdown is when the source language is JavaScript itself because we can't make simplifying assumptions. The median slowdown we get on the Kraken benchmark squite is 20x. These are slowdowns on a $200 ChromeBook. We also have results from the four major browsers on a desktop machine.
No! Stopify is a stand-alone component that applies to the output of existing compilers. Therefore, it would be easy for an IDE to offer a fast "release mode" (without Stopify) and a slower "debug mode" (with Stopify) that users can choose between.
Stopify runs programs on the main JavaScript thread, which gives you full access to the DOM, the network, etc. This is particularly important for many web-based IDEs that rely on graphics. A Web Worker would give us to ability to run a long-running computation and kill it, but would make DOM access much harder. Moreover, a Web Worker does not provide provide the rich execution control that Stopify provides, e.g., pausing, breakpointing, and deep stacks.
We think WebAssembly is awesome! However, at the moment, it is really designed to be a target for C/C++. Currently, garbage collection, threads, tail calls, and host bindings (e.g., access to the DOM) are in the feature proposal stage. Threfore, WebAssembly today does not provide enough features to prototype a Stopify-like solution. As WebAssembly evolves to support higher-level languages, web-based IDEs will want to use it. For that to happen, WebAssembly will need to support the kind of execution control that Stopify provides for JavaScript.
Yes! Stopify implements first-class continuations for JavaScript, so you can easily use it to build anything that first-class continuations allow. Let us know what you do with Stopify!
The GitHub repository has more information on how to use Stopify. If you do use Stopify, please let us know and acknowledge Stopify on your web page if possible. Stopify is developed by academics and evidence of its impact will help us continue development.
There are three kinds of errors that you may encounter on this demo site: