What are the differences between wasm-bindgen, asm.js and Emcripten?

1.1k views Asked by At

I'm struggling to get webpack working with a set of WebAssembly files compiled using wasm-bindgen.

Even if this could be just an issue with webpack, it made me realise I don't fully grasp the differences between these quirky WebAssembly tools.

1

There are 1 answers

0
Bumsik Kim On

WebAssembly module that was compiled using wasm-bindgen and Emscripten

This doesn't make sense. You are completely mixing everything, and the issue you linked shouldn't be applied to your problem. There is no relationships between wasm-bindgen and Emscripten.

Firstly, asm.js was a first effort to run C/C++ (or Rust) code in a browser and is considered the precursor to WebAssembly. It is a subset of JS that C/C++ code can be compiled to. An asm.js-compiled C/C++ code can run in any browser because it is JS and will be more performant in many browsers because it is a highly-optimized subset of JS. However, asm.js is typically less performant than WebAssembly.

For the others, in short:

  • Emscripten is a C/C++ compiler toolchain for WebAssembly/asm.js.
  • wasm-bindgen is a Rust binder generator to interact with JS code.