Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Emscripten with Bryan Rockwood

Nebraska JS
November 05, 2013

Emscripten with Bryan Rockwood

NebraskaJS Lightning Round, November 2013

Nebraska JS

November 05, 2013
Tweet

More Decks by Nebraska JS

Other Decks in Programming

Transcript

  1. What Is Emscripten? ! • A bridge between C/C++ and

    JavaScript! • Works with LLVM bitcode (produced by llvm-gcc or clang)! • Generates asm.js formatted JavaScript! • Works anywhere JavaScript will run (browsers, node, etc)
  2. How Do You Use It? • Visit https://github.com/kripken/emscripten for install

    instructions (or simply Google ‘emscripten’) • SDK provides a toolchain to interact with C/C++ • emconfigure/emmake to compile an existing project • emcc to compile .c/.cpp files manually
  3. What’s My Use Case? • HTML5 Weather Application • Contouring

    • Library originally written in JavaScript • Converted to C • Compiled back to JavaScript • Queue Inception *BONGGG*
  4. Why Go To All This Trouble? • Large files, lots

    of grid points (example is 614x428) • Original JS code was around ~130ms to ~160ms in Chrome and Firefox, respectively • Native C version is ~26ms • Chrome was ~88ms per grid • Firefox hit ~40ms per grid (?!) • Code is cross platform • OpenGL is compiled to WebGL
  5. A Few Gotchas… • The other browsers don’t fair so

    well (IE11 looks much better) • Not all C calls optimized for JS (hypot) • Editing and debugging code “difficult” • Have to get into the mindset of working on a heap with things like ‘malloc’ and ‘free’
  6. Future Work • Up next is finishing integrating emscripten compiled

    Proj4 • Start learning OpenGL ES for Emscripten WebGL work • Tie C libraries into iOS application
  7. Questions/Comments? • Reach me on Twitter @BRock97 • I’m also

    on Google+ at 
 https://plus.google.com/+BryanRockwood • Email at [email protected]