WasmGC: Cutting Out the Middleman Garbage Collector
Programming languages generally fall into two camps: those with garbage collection (Kotlin, PHP, Java) and those with manual memory management (C, C++, Rust). For Wasm, this distinction matters because of how these languages are brought to the web.
When you compile a garbage-collected language to WebAssembly, you are not just shipping the language's code. The runtime—including its parser, standard library, and garbage collector—also has to be compiled into the Wasm binary. This is redundant, as the Wasm execution environment in browsers such as Chrome runs on V8, which already includes a high-performance garbage collector.
WasmGC solves this duplication. Instead of shipping a custom GC with every language runtime, WasmGC lets the engine's existing garbage collector handle memory reclamation. Ports of languages like PHP no longer need to bring their own collector to the party.
Initially, enabling WasmGC required a flag, but it is now enabled by default and has reached Baseline Newly available status. This means developers can rely on it across major browsers without feature detection or fallbacks.
Tail Call Optimization: Turning Recursion Into Loops
Tail call optimization (TCO) is a compiler technique that eliminates the overhead of certain function calls. When a function's final action is a call to itself or another function (a call in tail position), the compiler can discard the current stack frame and just jump to the new function. This transforms recursive functions into constant-space iterations.
The impact is clear in a simple recursive C function that sums a linked list:
int sum(List* list, int acc) {
if (list == nullptr) return acc;
return sum(list->next, acc + list->val);
}
Without TCO, every recursion depth level adds a frame to the call stack, consuming O(n) space. Long lists risk a stack overflow. With optimized tail calls, the function runs in O(1) stack space:
int sum(List* list, int acc) {
while (list != nullptr) {
acc = acc + list->val;
list = list->next;
}
return acc;
}
Functional languages depend on this mechanism. They lean heavily on recursion, and pure ones like Haskell don't offer loop primitives at all. Without TCO, non-trivial programs in these languages would exhaust the stack almost immediately.
WebAssembly lacked native tail call support until the Tail Call Extension proposal was standardized. With the feature now Baseline Newly available, engines can compile calls in tail position into jumps rather than reserving new stack frames.
What Baseline Status Means in Practice
WasmGC and tail call optimizations are now part of the interoperable web platform. Both features enable more efficient execution for a broader set of languages and workloads. Google Sheets, for instance, has already leveraged WasmGC for its calculation worker, demonstrating the concrete performance and footprint gains available to real-world production apps.



