Skip to content

Conversion to javascript

kripken edited this page Apr 1, 2012 · 7 revisions

Conversion to Javascript

Emscripten is our tool to convert C++ to JavaScript through LLVM, including full LLVM optimizations. See demos on that page for previous projects ported using it, many of which are larger than Sauerbraten, and some of them also are very performance sensitive (Box2D, Bullet). So there is not much new here from a C++ to JS perspective, we are using a known useful technology.

Problems are still possible though. Most likely are minor missing libc functions which we will add.

Good stuff

  • Just 120K lines of code
  • No exceptions
  • No STL
  • No RTTI
  • No 64-bit ints
  • Correction: There are a small number of places with 64-bit ints. We need to be careful about them: scaletexture,endianswap64,endianswap<..>,crypto.cpp
  • Code builds in Clang 3.0 as-is

Bad stuff

  • CubeScript bytecode interpreter, like all interpreters, will not be that fast in JS
  • Floats are massively used, they will be doubles in JS

Tasks

  • Confer with eihrul when is a good time to snapshot Sauerbraten SVN.
  • This is a short project, we should not do any syncing from them. (Long-term, the hope is to get our work upstream into Sauerbraten so syncing wouldn't matter in that case either.)
Clone this wiki locally