Why is WebAssembly a second-class language on the web?
WebAssembly remains second-class on the web because it can only load code and reach Web APIs through JavaScript. That forces arcane instantiation boilerplate, language-specific glue code from tools like wasm-bindgen and embind, JS-centric documentation, and real runtime overhead. A 2020 TodoMVC experiment with the Dodrio Rust framework found that removing JS glue cut DOM-update time by 45%. The esm-integration proposal, being implemented in Firefox, simplifies loading, and the WebAssembly Component Model with WIT interfaces is proposed as a standardized artifact that could let Wasm call Web APIs directly with no JavaScript in between.
Related posts
- Introducing the WebAssembly JavaScript Promise Integration API
V8 mediumAdeptJSPI lets WebAssembly code written against synchronous APIs call asynchronous Web APIs. It intercepts Promises returned from wrapped JavaScript imports, suspends the Wasm computation, and resumes it from the browser's event loop when the Promise resolves. Wrapped exports return a Promise instead of a direct value. JSPI changes neither JavaScript nor Wasm, and suspend/resume costs are roughly constant: a deliberately bad Promise-based Fibonacci benchmark puts each JSPI'd call at about 1μs. The API is at phase 4 and ships in Chrome 137 and Firefox 139. Emscripten examples show `-s JSPI` with `EM_ASYNC_JS`, plus a trampoline pattern that lazily fetches and instantiates a Wasm module on first call.
- Bringing Javascript to WebAssembly for Shopify Functions
Shopify Engineering mediumAdeptShopify runs JavaScript in Shopify Functions by compiling the QuickJS interpreter to WebAssembly/WASI via Javy. JIT engines like V8 can't run inside Wasm, so QuickJS fills the gap. Embedding the engine with the user's bytecode produced modules of 800KB or more, well over the 256KB limit. Shopify got around this with an ad-hoc dynamic linking scheme built on Wasmtime's linker: a shared "javy_quickjs_provider_v1" library exposes realloc and eval_bytecode, so each function shrinks to a roughly 220-byte stub plus its bytecode, and the engine can be precompiled and patched centrally. The minimal Javy runtime adds POSIX-like stdin/stdout APIs on a Javy global and a Rust-implemented UTF-8 TextEncoder/TextDecoder, but does not yet enable the event loop.
- A new way to bring garbage collected programming languages efficiently to WebAssembly · V8
V8 hardMasterGarbage-collected languages like Java, Kotlin, Dart, Python and C# can reach WebAssembly in two ways: compile an existing language VM to linear-memory WasmMVP, or lower the language's objects onto WasmGC structs and arrays managed by the host VM's garbage collector. WasmGC produces smaller binaries because no GC or malloc is shipped, collects cycles between JS and Wasm at fine granularity, sees stack references without shadow stacks, and avoids linear-memory fragmentation. It also reuses the browser's generational and incremental GC and integrates with DevTools heap profiling. The costs are substantial new toolchain work and possible compromises in language semantics, since struct fields have fixed indexes and types and there are no interior pointers, whereas a traditional port preserves exact semantics with little effort. Later sections cover V8 and toolchain optimizations for WasmGC, with benchmark numbers.
- Intro to Wasm in Deno
Deno mediumAdeptDeno 2.1 lets Wasm modules be imported directly like JavaScript modules, with their exports understood and typechecked. A hand-written WAT `add` function is compiled with wat2wasm and imported into Deno. The second example uses the wasmbuild CLI, which wraps wasm-bindgen, to scaffold a Rust crate and generate JS glue, .d.ts types and a .wasm binary, so Rust functions and structs can be called from JavaScript. Production use typically compiles Wasm from Rust, C++ or Go rather than writing WAT by hand.
- Introducing the JetStream 3 Benchmark Suite
WebKit hardMasterJetStream 3 replaces JetStream 2's separate Wasm Startup/Runtime scores with the JavaScript-style first-iteration, worst-case and average-case scoring. The old scheme broke once engines hit sub-millisecond startup that Date.now() rounded to zero, giving infinite scores. The suite also favors larger workloads over microbenchmarks. WebKit details the JavaScriptCore work behind its results. Inlining WasmGC object fields into one allocation gave about 40% on the WasmGC subtests, and removing per-object destructors gave about 40% on Dart-flute-wasm. Other work inlines bump-pointer allocation into the BBQ and OMG tiers, uses Cohen's display for constant-time subtype checks, makes priority-based non-local inlining decisions, and profiles indirect calls for guarded inlining.