[gambit-list] Compiling Gambit Scheme to JavaScript

Hendrik Boom hendrik at topoi.pooq.com
Wed Mar 14 10:46:46 EDT 2012


On Tue, Mar 13, 2012 at 11:10:11AM -0400, Marc Feeley wrote:
> I was inspired by the ClojureScript project, a Clojure to JavaScript compiler, to look into the feasibility of a JavaScript back-end for Gambit.  A JavaScript back-end would allow running Gambit programs in web browsers.  Moreover, Scheme objects, including closures and continuations, could be sent between a Gambit Scheme program running on the browser and a Gambit Scheme program running on the server.
> 
> I did a fairly direct translation of the GVM code for the fib function into JavaScript (see the code attached below which interleaves the GVM code and JavaScript code).  Under V8 on a recent Mac Book Pro, this JavaScript program runs about 10 times slower than when the Scheme program is compiled with the C back-end (and 4 times faster than when the Scheme program is interpreted with gsi).  This is not so bad considering that JavaScript is a dynamic language with more overhead than C.  Moreover, for event-driven programs, which are most of the time waiting for input, this is probably an acceptable level of performance.
> 
> If anyone would like to pursue this idea, please let me know.

There's also Google's Opa project,  Opa, as I understand it, 
resembles OCaml but gets compiled to javascript on the browser and 
something else on the server and manages to be completely transparent as 
to what runs where and even distributes cleanly into the so-called 
Cloud.

-- hendrik



More information about the Gambit-list mailing list