Emscripten - LLVM to Web Compiler

Mar 02, 2020 • ☕️ 1 min read

Emscripten compiles C and C++ to WebAssembly using LLVM and Binaryen. Emscripten output can run on the Web, in Node.js, and in wasm runtimes. Using Emscripten you can:

  • Compile C and C++ code into JavaScript
  • Compile any other code that can be translated into LLVM bitcode into JavaScript.
  • Compile the C/C++ runtimes of other languages into JavaScript, and then run code in those other languages in an indirect way (this has been done for Python and Lua)!

Emscripten provides Web support for popular portable APIs such as OpenGL and SDL2, allowing complex graphical native applications to be ported, such as the Unity game engine and Google Earth. It can probably port your codebase, too!

While Emscripten mostly focuses on compiling C and C++ using Clang, it can be integrated with other LLVM-using compilers (for example, Rust has Emscripten integration, with the wasm32-unknown-emscripten and asmjs-unknown-emscripten targets).

Practically any portable C or C++ codebase can be compiled into JavaScript using Emscripten, ranging from high performance games that need to render graphics, play sounds, and load and process files, through to application frameworks like Qt.

Emscripten

This is a high level view of the Emscripten toolchain, the main tool is the Emscripten Compiler Frontend (emcc). This is a drop-in replacement for a standard compiler like gcc.

The whole toolchain is delivered in the Emscripten SDK, and can be used on Linux, Windows or macOS.

Emscripten has been used to port Unreal Engine 3, SQLite, MeshLab, Bullet physics, AutoCAD,and the Qt application framework.

Reading More

Polynomial Rolling Hash

A hash function used in Rabin–Karp's string search algorithm

Bull - queue system for handling distributed jobs and messages in Node

Bull is the fastest, most reliable, Redis-based queue for Node. I have been using it for years to handle async jobs and schedule messages

Yeoman Scaffolding System

Scaffolding system allows for rapidly getting started on new projects and streamlines the maintenance of existing projects.

JavaScript Build Tools

This is a confusing and blurring category in JavaScript tooling ecosystem