Whalesong: a Racket to JavaScript compiler
hashcollision.org
hashcollision.org
This is huge because with powerful control operators like call/cc, you can simulate pre-emptive multithreading within a browser tab. This gives the runtime:
- The ability to simulate synchronous functions backed by asynchronous library calls (e.g. apparently make a synchronous request to a URL from the program's point of view, but have it backed by an AJAX request) - The ability to add a pause and/or stop button to an IDE within a browser tab, even if the program goes into an infinite loop
In fact, work on Whalesong (and a few earlier prototypes) more or less run the Racket-using parts of www.wescheme.org which 10s of thousands of students use each year.
Most x-to-JS implementations don't have this level of feature richness; Doppio and GopherJS are two that have similar levels of execution control.
I worked in the same office as dyoo while he was implementing Whalesong about 5 years ago, and learned a ton from him and from the system. Pyret and code.pyret.org directly built on some of the code for the "framework to program the web in functional event-driven style" in reactors (https://www.pyret.org/docs/latest/reactors.html). Whalesong's APIs for programmatically saving and restoring the stack inspired the ones we use in Pyret, as well.
https://cs.brown.edu/~sk/Publications/Papers/Published/yk-wh...
Results range from 20x to 100x slowdown – just fine for the games and animations middle- and high-school students write for Bootstrap, for example.
I believe a more up-to-date (but less complete?) effort is Racketscript: https://github.com/vishesh/racketscript But, with Racketscript, I believe only a subset of the language is supported.
IIRC, Clojurescript was able to make traction because they succeeded in mostly porting Clojurescript to Clojurescript. With the work to move Racket to Chez Scheme, they are writing more of Racket in Racket, so maybe that'll make Javascript an easier target?
Of course, with Web Assembly, perhaps things will be even easier still.
Latest non-Readme commit: 4 years ago. Not sure this is still relevant.
https://github.com/soegaard/whalesong
There is also an extant issue regarding Racket 6.3 support that HN readers might want to address:
I currently have to write simple javascript code, which is repetitive enough that I wrote some python helpers to generate it. I'm pretty sure a Lisp language (which are known to be good at designing DSL) could help even more, but the ecosystem is quite big for a newcomer.