An early preview of experimental Bun + JSC with ahead-of-time compilation
For Claude Code's CLI: 24% faster startup, 48% lower memory, 46% lower CPU, and nearly 2x larger binary size
For Claude Code's CLI: 24% faster startup, 48% lower memory, 46% lower CPU, and nearly 2x larger binary size
Sep 29, 2026 · 1:06 AM UTC
69
65
1,376
146,141
Most JavaScript usage is just-in-time compiled.
As code runs, types of values are watched and when a function runs frequently enough, a faster specialized version of that function is compiled on-demand.
Ahead of time compilation bakes that work into the executable itself.
As code runs, types of values are watched and when a function runs frequently enough, a faster specialized version of that function is compiled on-demand.
Ahead of time compilation bakes that work into the executable itself.
1
1
167
12,522
The cost of ahead-of-time compilation is less information about the types is available.
In native languages like Rust or Go, numbers specify double or int, a sign, and a size.
TypeScript is more flexible and less specific, which makes performance optimizations harder.
In native languages like Rust or Go, numbers specify double or int, a sign, and a size.
TypeScript is more flexible and less specific, which makes performance optimizations harder.
6
1
130
8,869
In this prototype, a limited amount of TypeScript syntax is used to propagate type information.
2
1
79
6,923
Generally, ahead of time compilation results in slower peak JavaScript execution than just-in-time compilation.
We think a stricter flavor of TypeScript and locking down modifications to builtins like Array & Object can close most of the gap.
We think a stricter flavor of TypeScript and locking down modifications to builtins like Array & Object can close most of the gap.
4
0
87
10,142
There are a lot of optimizations that aren’t implemented yet.
I want the binary size growth to go down a lot more (it started at 1 GB).
It needs to support sized types like uint32_t and propagate more detailed types.
There’s no separate checker to run and no diagnostics
I want the binary size growth to go down a lot more (it started at 1 GB).
It needs to support sized types like uint32_t and propagate more detailed types.
There’s no separate checker to run and no diagnostics
3
0
62
6,886
AoT uses Bun’s bundler & parser to parse typescript, tags types to JavaScriptCore via a typecheck bytecode intrinsic, and compiles the bytecode to machine code via B3 (what JSC’s JITs use)
This keeps the JavaScriptCore changes well-contained, so that syncing with upstream WebKit isn’t complicated
This keeps the JavaScriptCore changes well-contained, so that syncing with upstream WebKit isn’t complicated
1
0
66
6,423
@jarredsumner what happens when a baked in type guess is wrong at runtime
1
0
5
2,434
@jarredsumner @sseraphini Do you plan on supporting direct FFI with this? As in, link a C function?
0
0
7
1,041
@jarredsumner 24% faster startup and 48% lower memory usage is a serious improvement.
0
0
4
1,272
@jarredsumner Just rewrite Claude Code in a real language already
1
0
15
1,527
@jarredsumner With Perry we did that a few months ago: x.com/realamlug/stat…
Been optimizing ever since, and the latest main of Perry gets it really performant. Post coming soon about that. :)
But glad to see everyone is now trying to compile JS/TS.
Been optimizing ever since, and the latest main of Perry gets it really performant. Post coming soon about that. :)
But glad to see everyone is now trying to compile JS/TS.
A month ago, I pointed Perry at the 13 MB minified cli.js that npm ships for Claude Code and asked for a native binary.
No Node. No JIT. One executable.
It logs in, streams a real answer, exits clean.
160 compiler bugs later.
0
0
9
1,501
@jarredsumner Experimental means he’ll merge it in two weeks
0
0
9
500
@jarredsumner This is the way. I have been playing around with something similar I called ChadScript, an AOT-compilable subset of TS. The Bun version will be a game changer though, nice work. cs01.github.io/ChadScript/
1
0
3
1,752
@jarredsumner Bun 披露与 JavaScriptCore 的实验性提前编译:Claude Code 命令行启动约快 24%,内存约降 48%,CPU 约降 46%,代价是二进制体积接近翻倍。代理工具一天要冷启动很多次,运行时税会进总账单;用体积换冷启动,是在给高频命令行代理重新定价。
0
0
1
1,531
@jarredsumner I didn't understood the 2x binary size. Can Anyone explain that?
1
0
1
1,206
@jarredsumner drop the "script". just "java". cleaner that way.
0
0
3
360
@jarredsumner That binary size is insane. Definitely has to go down.
0
0
1
340
@jarredsumner I'm curious what happens to stuff like "const a: any = JSON.parse(...)". I mean how could this possibly be optimized, there is zero knowledge about anything.
1
0
1
1,252
@jarredsumner does it do "max optimize everything"?
but due to the dynamism of JS that may be pretty hard, bytecode was a great and cheap step, going further requires some assumptions I believe
but due to the dynamism of JS that may be pretty hard, bytecode was a great and cheap step, going further requires some assumptions I believe
0
0
1
279
@jarredsumner @bunjavascript Imagine a world where this gets merge into WebKit/JSC
0
0
1
292
@jarredsumner how are you getting the compiled code into the binary? is it unlinked FTL? this whole unlinked JIT code stuff in jsc seems interesting
0
0
0
80
@jarredsumner How does this differ from the existing compile parameters in bun?
1
0
0
947
@jarredsumner Is it statically inferring types on the JavaScript?
0
0
0
542
@jarredsumner What kind of optimization pipeline bun AOT is currently using? Are the types from typescript hints are being used or this is coming from "js" again? Does it do something like HarmonyOS do for arkts?
0
0
0
459
@jarredsumner AOT is experimental or something readily available GA?
0
0
0
384
@jarredsumner It does look promising, but +80% in size is a little too much IMO 👀
0
0
0
67
@jarredsumner How about hybrid aot-jit like android runtime? Of just transpile typescript to pure aot lang that already has years of optimization? Or to llvm ir directly? Anyone just use static type plugin anyway (typescript), so remove dynamic typing entirely
0
0
0
2,133
@jarredsumner This working, will make me move my code from Node to Bun. Wonder if you could get better perf by switching to v8.
0
0
0
499





































