|
|
|
|
|
by jpolitz
3109 days ago
|
|
Nice! Something like this is super-important for user experience. This is a problem we've thought a lot about with Pyret, and have different concrete solutions. Rather than use heuristics that turn long-running computations into errors, we capture continuations and yield to the browser periodically. This allows long-running computations to eventually complete, while allowing the user to fully interact with buttons and the page while it's happening. This generalizes to nice abstractions for functional event loops and ways to manage asynchronous APIs for novices. The Doppio JVM and the Whalesong compiler for Racket have similar underlying approaches. It's quite a bit of effort to work around this inherent limitation of the browser's evaluation model for web-based IDEs! |
|
See https://amasad.me/js-debugger
It worked well enough and was able to build a couple of demos on top of it (last time I checked chrome broke some of my demos so try them on other browsers). However, I think it's quite a hack and that the proper solution would be to build a JS VM. There are still issues to be worked out there like the problem that you can't instrument native code (say an event handler, or built-in functions) and that there are things that are inherently synchronous in the browser that you can't make async (e.g. event bubbling).
However, one of Repl.it's goal is to support every language ever existed so building and maintaining our own virtual machines would be quite an undertaking for our 3 person team.
What I'm hoping for is that we sometime soon leverage WASM to compile down an existing JS VM.