In 30 Sekunden
Bun creator Jarred Sumner says the way to trust a large agent-built compiler was to test it against software and test suites that existed before the project. His team compared three execution modes, fuzzed for differences and rewrote the compiler five times when performance or build speed fell short. The result, he says, used about four times less memory and started Claude Code twice as fast in internal use. He chose to speed up JavaScript instead of rewriting Claude Code in Rust because porting its tests would weaken the comparison.
- 1A Rust rewrite would have required rewriting the tests tooBun’s TypeScript tests could check both its Zig and Rust implementations. Claude Code’s tests would need porting, so Sumner chose to make JavaScript faster instead.
- 2The internal build used about four times less memorySumner says the ahead-of-time compiler also made Claude Code start about twice as fast in internal testing.
- 3Tests older than the project provide an independent checkThe team reused Bun, WebKit, Test262 and Claude Code tests, then compared the output of three ways of running the same program.
- 4Write a large batch, then compile and repair itSumner delays repeated builds during the initial burst and follows with compilation and test fixes. He says much of the millions of lines is test code.
- 5A 50-second build triggered another rewriteDespite acceptable runtime performance, the fourth version compiled too slowly; the fifth brought build time below 20 seconds.
- 6Hourly scorecards exposed regressions during the buildLong-lived agents worked on parts of the compiler while regular comparisons showed how priority metrics changed.
Das Wichtigste
- Choose projects whose results can be checked against independent tests that already exist.
- Compare the same program across implementations and use generated cases to expose discrepancies.
- Track build time, runtime and correctness throughout; a faster program can still be too slow to compile.
- Keep agents on long-lived tasks when retaining code context saves repeated work.
- Verify that tests actually catch failures and remeasure performance as the project changes.
Den bearbeiteten Text nach Kapiteln lesen
Why Bun needed a compiler before execution
Sumner says compiling JavaScript during execution costs substantial CPU time. The team built a compiler that does more work ahead of time and rewrote it five times.
I recently merged a pull request containing several million lines of code to add an ahead-of-time compiler to Bun, the JavaScript runtime that powers Claude Code. Rather than compiling code as the program runs, this compiler does the work beforehand. The question was how to ship such a large body of agent-written code with confidence.
The initial request was to make Claude Code faster and use much less memory, with permission to change Bun or WebKit, whose JavaScriptCore engine Bun uses. Over a little more than a month, the compiler went through five rewrites; I nearly shipped one version before realizing that it took too long to build.
How you can verify the result constrains a large project more than the particular implementation you choose. The first question is how to establish that the code works and is not buggy, because that determines which approaches can be trusted.
For a typical JavaScript application, I estimate roughly half of CPU time can be spent compiling code on demand. That overhead matters especially when many Claude Code sessions run at once. Ahead-of-time compilation moves work out of the running session instead of compiling as execution proceeds.
Keep the tests when changing the implementation
Rewriting Claude Code in Rust would have required porting its tests. The team instead accelerated JavaScript and checked results against existing suites.
We considered rewriting Claude Code in Rust, but chose not to. Bun was suitable for a Rust rewrite because its tests were written in TypeScript and could run against both the old Zig version and the Rust version. Claude Code’s own TypeScript tests would have needed porting, making them less trustworthy as an independent check.

Instead, we tried making JavaScript faster so Claude Code would not need a Rust rewrite. In our internal use the result used about four times less memory and started about twice as fast. The compiler was being tested internally and was due to reach external users soon.
One comparison involved the TypeScript 7 compiler, which was manually rewritten from JavaScript and TypeScript into Go. Sumner says its single-threaded JavaScript version compiled by Bun ran faster than the single-threaded Go port in the comparison he showed; the ahead-of-time compiler did not yet add threads.
TypeScript annotations do not have to be correct, so the compiler treats types as predictions rather than facts. It can make a faster direct field access when it can establish the relevant type behavior, and otherwise must check at runtime.
Existing tests are particularly valuable because they predate the project and its agents. We could use Bun’s own tests, WebKit tests, the JavaScript conformance suite Test262 and Claude Code’s tests, and run Bun’s test runner in the new compilation mode as well.
The compiler has two intentional breaking changes, mostly related to security and prototype pollution, which also help performance. I separate those known differences from unexpected failures rather than assuming every existing test must pass unchanged.
Compare three versions and fuzz for differences
The compiler runs programs in three modes and compares their behavior. Agent-generated cases add coverage, while batching helps limit repeated builds.

We can run an application three ways: through the ordinary just-in-time compiler, through the ahead-of-time compiler with TypeScript types, and through the ahead-of-time compiler after removing types. If all three behave alike, that is evidence for that application. Claude can also generate programs for fuzzing, which tries many patterns to find discrepancies.
Most of the code volume is tests, and five rewrites also contributed to the total. My approach is to write a large batch first, then fix it: make it compile, run tests and check that it really works. During the initial burst, repeated builds can waste time, so I prefer to build once after the batch.
Five rewrites traded runtime gains against build speed
Early versions improved memory and startup but had code-quality or compilation-time problems. The fifth built in under 20 seconds, Sumner says.
The first compiler leaned heavily on existing JavaScriptCore code and produced a Claude Code build that used about a gigabyte of memory. Later we added a TypeScript type checker to Bun and asked Claude to use it; startup improved about twofold and memory use fell by roughly threefold, but the generated code still had unacceptable design problems.
One example treated any access to a property named archive as potential use of Bun’s archive API. I looked at it and decided we could not ship it. I also found that large planning exercises could produce an unreasonable number of Markdown files, including 1,500 documents.
For the third compiler iteration I used 140 agents at once to write code in parallel and then get Claude Code running. The fourth version produced good code with similar runtime performance, but compilation took about 50 seconds for Claude Code; even single-digit waits for smaller projects were too long for users accustomed to JavaScript.
The fifth rewrite brought the build time below 20 seconds and produced code I considered shippable. Another rewrite remained possible later. I cautioned that a model can size up an idea incorrectly and persuade itself not to pursue it; some ideas might deserve another attempt.
Long-lived agents and hourly measurements
Sumner describes agents that retain context, scorecards and fuzzing. He also identifies interpreter-heavy programs where the compiler may not be faster.
My earlier Bun workflow leaned heavily on Claude Code workflows. With newer models, outside the initial burst of writing, I mostly use long-lived subagents. They retain relevant code in their context and can keep working without repeatedly rebuilding that context.

A project this large can be difficult to follow, so I asked for an hourly scorecard with the metrics we cared about. Slack updates compared the previous result with the current one, making it easier to see whether numbers improved or regressed.
Most of the tests were not invented by the agent during this project. We extended an existing V8 JavaScript engine fuzzer to cover TypeScript types as well, and I stress that a team also has to check that its tests actually detect failures; a test that never finds bugs can create false confidence.
On the benchmarks I showed, ahead-of-time compilation generally beat the just-in-time version, but not always. Programs that frequently rely on the interpreter, such as through eval or dynamically created functions, can be slower. The compiler also bans assignments to Object.prototype, a change intended to prevent a class of prototype-pollution vulnerabilities.
The human job is to question and remeasure
Sumner steers agents with questions and checks benchmark results. He emphasizes test quality, frequent measurement and ambitious targets.
What do I actually do all day? I often tell agents to continue, but also ask leading questions: why are we doing this, can we do it differently, and what is taking so long? Models can invent restrictive rules or underestimate what they can accomplish, so I push them to investigate further.
In the JetStream 3 JavaScript benchmark, I showed Bun outperforming JavaScriptCore’s and Node.js’s just-in-time engines on most tests. Throughout the work, Claude Code helped build Bun’s compiler, and we used a Claude Code build produced by that compiler.
For a large agent project, testability comes first, and the tests themselves must be checked. Keep measuring actively: with so much changing, it is easy for performance to regress without anyone noticing. Before a project ships, a rewrite can sometimes be easier than refactoring.
I also encourage the models to pursue ambitious improvements. Without repeated nudges, they may settle for tiny gains when larger ones could be possible. Sumner says the compiler can be tried through Bun’s canary release and its compile command.
Mehr aus diesem Kanal
21:22EN
20:24EN
19:56EN
56:08EN
14:28EN
18:30EN