Big Web App?
Compile It!

Alon Zakai / Mozilla

Compiling to JavaScript

JavaScript is standards-based and the only language that runs in all web browsers

You can run only JavaScript in browsers, but you can write in another language - if you compile it to JavaScript

First set of demos

BananaBread

Qt

Ruby

Compiling to JavaScript:
Nothing New!

  • 2006: Google Web Toolkit (GWT), Java to JS
  • 2007: pyjamas, Python into JS

Fast Java, C#

Actually, Java and C# have a similar predicament: Both languages depend on special VMs to be efficient

Source-to-source compilers for them lose out on the optimizations done in those VMs

AOT compilers for them can at least gain LLVM-type optimizations - but still something is missing

A Unified Approach?

Should we compile entire VMs from C/C++ to JavaScript, and implement JavaScript-emitting JITs?

Seems the only way to run most languages with perfect semantics + maximum speed

This is why I believe C/C++ to JavaScript translation is the core issue regarding compilation to JavaScript

Conclusion

Statically-typed languages and especially C/C++ can be compiled effectively to JavaScript

Expect the speed of compiled C/C++ to get to just 2X slower than native code, or better, later this year


Thanks for listening!
Questions?