When Correct Code Breaks: How Compilers Exploit Undefined Behavior

In 2009, a vulnerability was discovered in the Linux kernel that allowed privilege escalation. The code looked perfectly reasonable—a null pointer check designed to prevent crashes. But when compiled with optimization enabled, the check simply vanished. The compiler had every right to delete it. The code contained undefined behavior, and undefined behavior means the compiler can do whatever it wants. This wasn’t a compiler bug. It was the compiler doing exactly what the C standard allows it to do. Understanding this distinction is crucial for anyone writing systems code in C or C++. ...

10 min · 2010 words

How WebAssembly Actually Runs in Your Browser: From Stack Machine to Machine Code

In April 2015, Luke Wagner made the first commits to a new repository called WebAssembly/design, adding a high-level design document for what would become the fourth language of the web. The project emerged from a convergence of efforts: Mozilla’s asm.js experiment had demonstrated that a strictly-typed subset of JavaScript could approach native speeds, while Google’s PNaCl and Microsoft’s efforts in this space had explored similar territory. What none of these projects achieved was cross-browser consensus. WebAssembly was designed from the start as a collaborative effort, with formal semantics written in parallel with its specification. ...

10 min · 2099 words

How V8 Turns Your JavaScript Into Machine Code: The Four-Tier Compilation Revolution

When Google released Chrome in 2008, its JavaScript performance was revolutionary. The secret was V8, an engine that compiled JavaScript directly to machine code rather than interpreting it. But the V8 of 2026 bears almost no resemblance to that original design. Four compilation tiers, speculative optimization based on runtime feedback, and a constant battle between compilation speed and execution speed have transformed JavaScript from a “slow scripting language” into something that routinely outperforms carefully optimized C++ for many workloads. ...

13 min · 2601 words