Converting Julia to Javascript and WebAssembly

By: Julia – Alex Mellnik

Re-posted from: http://alex.mellnik.net/converting-julia-to-javascript-and-webassembly/

I have a “two language problem”, but not this two language problem.  I often find myself prototyping small data analysis projects in Julia, and then rewriting them as web applications using Angular & Typescript to make them easily accessible to a broad audience.  Much of the work is similar in Julia and Typescript (such as creating plots) so it’s not that annoying to translate, but occasionally I run into analytical code that is really painful to rewrite in Typescript.  Some tasks that I could accomplish in a few lines in Julia (usually with the help of a package) can turn into hundreds of awkward lines in Typescript.

I’ve always dreamed of the day that I could write arbitrary Julia code and have it run in a browser, and while we’re definitely not there yet, we’re getting closer.  One first step forward was made by Tom Short, who developed two distinct ways to generate Emscripten-friendly LLVM bitcode from Julia v0.7.  Recently, Mike Innes (with contributions from Tom) developed a new approach (Charlotte.jl) that works with Julia v0.6 and generates Javascript/WebAssembly directly from Julia.  See the source repositories for details on how to use them, and you can also try both out in your browser using demos that I put together at julia2js.gotfork.net.