Anthropic’s Bun Rust rewrite merged at speed of AI

DevOps

Version 1.3.14 of JavaScript toolkit released as last Zig version; a million lines of Rust code merged in gargantuan commit

A pull request with a Rust version of Anthropic’s Bun, a
JavaScript toolkit and runtime originally written in Zig, has been merged to
the main Bun repository. Thos comes just days after its author, Jared Sumner, said
“there’s a very high chance all this code gets thrown out.”

Sumner posted on X (formerly Twitter) five days ago that “99.8 percent of bun’s pre-existing test suite passes on Linux x64f
glibc in the rust rewrite,” a clue that what was initially described as an
experiment was likely to make it to production. Three days later, the Bun team
released version 1.3.14, with Sumner stating that if the Rust rewrite was
merged, “this would be the last version in Zig.”


Creator Jarred Sumner presented Bun in a launch video

Today that merge took place,
adding more than one million lines of code. Sumner said it passes Bun’s test
suite on all platforms, fixes some memory leaks, and shrinks the binary size by
between 3 and 8 MB. 

“Most importantly, we now have compiler-assisted tools
for catching and preventing memory bugs, which have cost the team an enormous
amount of development and debugging time over the years,” he said in a
comment. Performance is either neutral or faster, he said, though the codebase
is “the same architecture, the same data structures.” No async Rust
is used.

Bun users have hit memory leak issues when deploying it as a
production runtime. According to Sumner,
“Rust won’t catch all of these – leaks from holding references too long
and anything that re-enters across the JS boundary are still on us. But a large
percentage of that list is use-after-free, double-free, and forgot-to-free-on-error-path,
and those become compile errors or automatic cleanup.”

AI Slop? A pull request removing Zig source files from Bun was automatically flagged.

AI Slop? A pull request removing Zig source files from Bun was automatically flagged.

A second pull request, removing upwards of 600,000 lines of Zig code,
was automatically flagged by GitHub as “AI slop” and closed, but will
presumably reappear in some form.

The size of these commits makes them near-impossible for
humans to review. “What a nice reviewable little commit. I’m sure it will
not contain any bugs,” said one comment on the Rust merge.

Although the idea of the Rust port has been well received, the
speed of the transition has taken the community by surprise. In normal circumstances,
porting a major project so quickly would be risky, but this has been accomplished
using AI tools. According to Sumner, it is “essentially the same codebase
ported to Rust.”


Bun creator Jarred Sumner said that AI writes all the code

Asked whether the Rust version would be maintained mainly by
Anthropic’s Claude Code, Sumner said “this is already the status
quo; we haven’t been typing code ourselves for many months now. Even
pre-acquisition [by Anthropic] this was pretty much accurate.”

Sumner was formerly a strong Zig advocate, but Zig’s no-AI
policy is at odds with the Bun team’s way of working, and recent versions of
Bun use a Zig fork with contributions that cannot be merged upstream, and which
Zig’s maintainers said would not be welcome regardless of the AI aspect.

Version 1.3.14, the last one still to use Zig, adds a
built-in image processing API for decoding, transforming and encoding images.
It is designed as a drop-in replacement for the Sharp image processing library for Node.js. The new release also adds experimental
support for the HTTP/3 (QUIC) protocol in Bun’s integrated server. The full
release notes describe these and other new
features.

Is it possible to move this fast and not break things? Bun’s
migration from Zig to Rust will be watched with interest by AI advocates and
sceptics alike. ®

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *