[racket] Racket in a browser?

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Apr 10 17:21:07 EDT 2011

25 minutes ago, Jens Axel Søgaard wrote:
> 2011/4/10 Shriram Krishnamurthi <sk at cs.brown.edu>:
> >> Does the current bytecode to JavaScript compiler cover the whole language?
> >
> > No, we definitely have the "library problem".
> >
> >> A direct Racket bytecode to JavaScript compiler ought to be
> >> faster/smaller/better etc.
> >
> > I don't understand this.  "direct" = ?  How would it be more "direct"
> > than the current one?  You're making a comparative with at least two
> > undefined parts.
> 
> I am talking about the current one (which I see as a direct
> compiler, since there is no LLVM layer). It wil will be both faster
> and smaller.

I think that what Shriram is talking about is the fact that the
runtime support that you need is very non-trivial.  If it was, then
you could just as well write an x86 emulator (interpreter or compiler)
and just run full applications in your browser.


> >> One advantage with the LLVM solution is that one is sure that the
> >> semantics of the parts of Racket that are implemented in C will
> >> be preserved. I am thinking such things as the numerical tower,
> >> whose C implementation contains quite a few functions that are
> >> non-trivial to implement directly in JavaScript.
> >
> > I don't know what the porting effort is to get Racket to LLVM.
> 
> I hope that's not neccessary. Here is what I had in mind: GCC has an
> LLVM backend.

(Last time I checked it was the other way around: LLVM had a GCC
front-end.)


> So compile Racket (with a disabled JIT) to racket.llvm with GCC, and
> then compile it with Emscripten.

... and this doesn't help with the runtime support that you need.
Here's a concrete example: that code will also have a GC in it, and
you'll end up running an emulated piece of code in JS to do the GC,
spending a good number of layers on work that JS already does.

In any case, there's nothing really special about LLVM in this context
other than the fact that someone wrote such a compiler.  It doesn't
change much how "direct" things are, because it's at a low enough
level that there's not much difference.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!



Posted on the users mailing list.