Follow your curiosity

What discovery has been shared with you?

Start with one fact. Explore it, go deeper, then follow whichever branch catches your imagination.

Choose subjects for a surprise

Exploring any topic

Begin your discovery

Your next discovery is one click away.

Choose one or more subjects above, or leave Any Topic selected and let curiosity decide.

Technology

WebAssembly for Portable High-Performance Computing in Browsers

Quick fact

WebAssembly was designed to be a compilation target so that code written in C, C++, Rust, and other languages can run at up to 80-90% of native speed in a browser.

Why this is interesting

You can run a full 3D game or a video editor right in your browser, but how does it run so fast when JavaScript is notoriously slow?

Read the full explanation

Understanding WebAssembly for Portable High-Performance Computing in Browsers

Imagine you are reading a recipe in a language you don't speak well. Even with translation, you might miss the nuances and it would be slower. JavaScript is like a high-level human language for browsers, but it's interpreted and optimized at runtime, which can be slow for heavy tasks. WebAssembly is more like a universal machine code for the web—a compact, low-level format that browsers can execute directly. When you compile your C++ or Rust program to WebAssembly, you get a binary file (.wasm) that the browser downloads, verifies, and runs in a virtual machine. The browser's engine understands this format natively and can execute it quickly, almost as if it were running on your computer's hardware, but safely inside a sandbox.

A deeper explanation

WebAssembly works by providing a virtual machine that executes instructions in a stack-based architecture. The .wasm module defines functions, types, and a linear memory space (a contiguous array of bytes). When a web page loads the module, the browser instantiates it, giving the program access to a stack and memory. The instructions are very low-level—similar to assembly language—so the JavaScript engine can translate them to native machine code just-in-time (JIT) and even ahead-of-time (AOT) in some browsers. Because the code is statically typed and has no garbage collection (for the core module), the engine can optimize aggressively. Portability comes from the fact that the format is standardized and executes deterministically across all browsers and platforms. The sandbox ensures security: the module cannot access the host system directly; it must go through JavaScript APIs or WebAssembly System Interface (WASI) for I/O. This combination of speed, portability, and safety makes WebAssembly the foundation for high-performance web applications, from computer vision to real-time data processing.

Keep FACTREE close

Internet access is required. Updates arrive when you reopen or reload the app. You may need to sign in again in the installed app.