Compiling Julia to Javascript for Web REPL

1,279 views
Skip to first unread message

Adam Savitzky

unread,
Feb 27, 2013, 2:46:55 PM2/27/13
to juli...@googlegroups.com
Hear me out. I may be crazy, but hear me out....

My mind was blown when I discovered that someone had built an LLVM to Javascript compiler:

Some of the demos are really impressive, especially the OpenGL and Qt demos.

Then I remembered that Julia is an LLVM-based language. We could, in theory, compile Julia down to Javascript. It's been done for Python, Lua, Ruby, and a few other languages.

I would ordinarily say that having a Javascript version of Julia would be useless, albeit cool, but then I realized it could be used for the Web REPL. The Web REPL has some problems. It's insecure, it crashes often, and behaves weird if you give it input it doesn't like.

If you go to http://repl.it/ you'll see a really nice Web REPL for Python and the other languages that have been compiled with emscripten. We could do something like that for Julia.

Would performance suffer? Yes, I'm sure, but javascript is pretty fast, and avoiding an http roundtrip for each request would probably make up for some of the performance lost by essentially using javascript as a VM. Would it be difficult to do? Absolutely. What are the implications in terms of JITing the code? I have no idea. I'm not too well versed in LLVM. Am I nuts? Probably.

Stefan Karpinski

unread,
Feb 27, 2013, 2:57:05 PM2/27/13
to Julia Dev
I've contemplated this quite a few times. The main issue is that Julia *includes* in Base a lot of things that other language wouldn't even begin to consider part of the language – LAPACK and DSFMT, for example. It might be possible, but the idea of compiling OpenBLAS via emscripten strikes me as terrifying / impossible. But then again, the whole concept of emscripten is pretty nuts and yet it works, so who knows?

One very limited thing that would help a lot would be being able to *parse* Julia in JavaScript. Then the web repl could know when an input was finished without talking to the server. Compiling flisp to JavaScript via emscripten is much more reasonable than all of Julia. Jeff's take on that, however, is that it would be better to just use a JavaScript Scheme implementation instead of flisp.

Stefan Karpinski

unread,
Feb 27, 2013, 3:07:38 PM2/27/13
to Julia Dev
Created an issue: https://github.com/JuliaLang/julia/issues/2418. This would actually make a fun self-contained project for someone new to Julia.

Eric Forgy

unread,
Jan 22, 2015, 8:25:27 AM1/22/15
to juli...@googlegroups.com
This issue was closed in favor of https://github.com/JuliaLang/julia/issues/9430

I am very interested in this project and I am new to Julia. Sadly, I'm also new to LLVM and pretty much clueless about low level stuff, but would love to learn.

Eric Forgy

unread,
Jan 22, 2015, 10:40:59 AM1/22/15
to juli...@googlegroups.com
Here is an inspiring article:


The video is awesome. I like this comment:

  1. MySchizoBuddy (April 4, 2013 at 4:17 pm)

    Will this finally open up a path for fast matrix computations in the browser. Matrix computations make the bases of any scientific and engineering application. I haven’t seen any of the mathematics C/C++ libraries being ported to js via emscripten. Is this due to lack of interest or difficulty?



Reply all
Reply to author
Forward
0 new messages