Emscripten Simple Portability

Marco Kuoni
WebAssembly
Published in
10 min readSep 25, 2023

--

C/C++ WebAssembly

Why does achieving simple portability of C/C++ programs to WebAssembly make sense?

There are several reasons for this, some of which are briefly listed here:

  • There are already large libraries of existing C/C++ programs.
  • There are problem-solving scenarios that cannot be optimally addressed in JavaScript.
  • It does not require a separate runtime and gets delivered already compiled. This not only saves memory but also enhances performance on end-user devices.
  • Multiple programing languages can be used in combination.
  • Trustworthy code from trusted sources can be utilized. A good example of this is libsodium, which brings the Networking and Cryptography (NaCl) library directly from the source to WebAssembly.

Emscripten lays the foundation to make this portability as easy as possible. Emscripten has been around for a long time and is developed by the two main contributors, Alon Zakai and Luke Wagner, who have also been involved in asm.js and now WebAssembly to this day. This project also builds upon the LLVM platform, with the backend have been switched from an asm.js compiler to a WebAssembly compiler in the meantime.

Implementing such portability is not a straightforward task. For example, the fact that a browser is typically a single-threaded environment poses challenges. Additionally, there are various interfaces with the…

--

--

Marco Kuoni
WebAssembly

CTO lemonbrain, BSc electrical engineering, cand. BSc computer science