When JavaScript developers want "multi-threading," they spin up Web Workers. But Web Workers operate on isolated memory spaces. Passing data between them requires serializing massive JSON objects or transferring ArrayBuffers, which introduces severe latency. In native C++ desktop software, threads share the exact same heap memory, allowing for instantaneous data access.
NitroIDE brings true, desktop-grade multi-threading to the browser by compiling POSIX threads (pthreads) directly into WebAssembly using Emscripten and SharedArrayBuffer.
When we compile our core C++ syntax engine, we pass the -pthread flag to the Emscripten compiler. Emscripten does something incredibly clever: it intercepts standard C++ std::thread creation calls and dynamically spawns a pool of JavaScript Web Workers under the hood.
The Shared Heap: To make this work, the WebAssembly instance is initialized with a WebAssembly.Memory object backed by a SharedArrayBuffer. All 4 spawned Web Workers are handed a reference to this exact same memory block. When Thread 1 updates a variable, Thread 2 sees it instantly without a single postMessage.
Because multiple threads can now overwrite the same memory address simultaneously, we rely on WASM atomics to implement C++ std::mutex. This allows our browser-based compiler to lock memory regions during write operations, preventing data races while leveraging 100% of the user's multi-core CPU.
Run our C++ compiler in the browser and watch it utilize all of your CPU cores.
Launch C++ Sandbox