All posts
Trending Tech

Bun Rewrites Its Core in Rust, Shrinks Binary by Up to 8 MB

Manaal Khan14 May 2026 at 11:53 pm4 min read
Bun Rewrites Its Core in Rust, Shrinks Binary by Up to 8 MB

Key Takeaways

Bun Rewrites Its Core in Rust, Shrinks Binary by Up to 8 MB
Source: Hacker News: Best
  • Bun's Rust rewrite has been merged and is available in canary builds
  • Binary size drops by 3 MB to 8 MB depending on platform
  • The rewrite fixes several memory leaks and flaky tests while maintaining the same architecture

What Just Happened

Jarred Sumner, creator of Bun, merged pull request #30412 on May 8, 2026. The PR rewrites Bun's core from Zig to Rust. It's now live in canary builds.

This is a big deal for the JavaScript runtime that has positioned itself as a faster, all-in-one alternative to Node.js. Bun handles package management, bundling, testing, and runtime execution. Rewriting its foundation in Rust gives the team access to the language's memory safety guarantees without sacrificing performance.

3-8 MB
Binary size reduction across platforms after the Rust rewrite

The Technical Details

According to Sumner's notes in the PR, the Rust rewrite passes Bun's entire pre-existing test suite on all platforms. It also fixes several memory leaks and flaky tests that had plagued the project.

The architecture stays the same. So do the data structures. Bun still uses few third-party libraries. And there's no async Rust, which is notable. Async Rust has a reputation for complexity, and avoiding it keeps the codebase more straightforward.

Benchmarks range from neutral to faster. Sumner didn't release specific numbers yet, but promised a blog post with details. The real win, as he describes it, is tooling: Rust's compiler catches memory bugs that previously cost the team enormous development and debugging time.

How to Try It

If you want to test the Rust-based Bun, run:

bash
bun upgrade --canary

Sumner asked users to file issues if they hit problems. He also noted there's still optimization and cleanup work before this lands in a stable release. Expect follow-up PRs.

Why Rust, Why Now

Bun was originally written in Zig, a systems language that offers manual memory control and C interop. Zig is fast and lean, but it lacks Rust's borrow checker. The borrow checker is Rust's signature feature. It prevents entire categories of memory bugs at compile time rather than runtime.

For a project like Bun, which handles complex operations like bundling, transpiling, and package resolution, memory bugs are a constant threat. They cause crashes, security vulnerabilities, and unpredictable behavior. Sumner's comment about the "enormous amount of development and debugging time" suggests these issues were a real drag on the project.

Rust also has a larger ecosystem and community than Zig. More developers know it. More tools support it. That could help Bun attract contributors.

What Stays the Same

The user-facing API isn't changing. If you're using Bun today, your code should work the same way after the Rust rewrite lands in stable. The architecture, data structures, and minimal dependency philosophy all remain.

This is a foundation change, not a product pivot. Bun is still Bun. It just has a more robust engine underneath.

ℹ️

Logicity's Take

What to Watch For

Sumner promised a blog post with more details. That should include specific benchmark numbers and a deeper explanation of the migration process. Given the complexity of rewriting a JavaScript runtime, that post will likely be a valuable case study for anyone considering a similar migration.

The canary period will reveal edge cases. If you depend on Bun in production, wait for the stable release. If you're curious or want to help find bugs, now's the time to test.

Frequently Asked Questions

Is Bun now written entirely in Rust?

The core has been rewritten in Rust. The overall architecture and data structures remain the same, and Bun still uses few third-party libraries.

Will the Bun Rust rewrite break my existing code?

No. The rewrite passes Bun's entire existing test suite. Your code should work the same way.

When will the Rust version of Bun be stable?

It's currently in canary. Sumner said there's still optimization and cleanup work before a stable release, but didn't give a specific date.

Is the Rust version of Bun faster?

Benchmarks range from neutral to faster according to Sumner. Specific numbers haven't been released yet.

Why did Bun switch from Zig to Rust?

Rust's compiler-assisted memory safety tools help catch and prevent bugs that were costing the team significant debugging time.

ℹ️

Need Help Implementing This?

Source: Hacker News: Best

M

Manaal Khan

Tech & Innovation Writer

Related Articles

Tesla's Remote Parking Feature: The Investigation That Didn't Quite Park Itself
Trending Tech·8 min

Tesla's Remote Parking Feature: The Investigation That Didn't Quite Park Itself

The US auto safety regulators have closed their investigation into Tesla's remote parking feature, but what does this mean for the future of autonomous driving? We dive into the details of the investigation and what it reveals about the technology. The National Highway Traffic Safety Administration found that crashes were rare and minor, but the investigation's closure doesn't necessarily mean the feature is completely safe.