Using the AI 'Claude,' all 530,000 lines of Zig code in the development tool 'Bun' were rewritten in Rust, and the creator of Zig also responded on his blog.



The development team behind the JavaScript runtime '

Bun ' has announced the completion of a full porting project to rewrite Bun's Zig code into Rust , which was carried out using the AI coding assistance tool 'Claude Code'. With approximately 530,000 lines of Zig code ported to Rust, a reduction in memory management-related bugs is expected.

Rewriting Bun in Rust | Bun Blog
https://bun.com/blog/bun-in-rust



My Thoughts on the Bun Rust Rewrite - Andrew Kelley
https://andrewkelley.me/post/my-thoughts-bun-rust-rewrite.html

Bun, a JavaScript runtime, is an all-in-one development tool that combines a fast execution environment with a package manager, bundler, test runner, and more. The initial version of Bun was developed over a year by its developer, Jared Sumner, using the system programming language 'Zig'.

However, Sumner says that Bun, which was developed in Zig, had a lot of bugs related to memory management, and the bug fix list was in a terrible state. So the Bun development team decided to migrate the entire codebase from Zig to Rust, which has better memory safety.

Regarding the migration, Sumner stated, 'I don't think Zig itself was the problem. We wouldn't have gotten this far without Zig, and I'm always grateful for it.' He then explained that until very recently, 'the choice of programming language for a project like Bun was a one-way decision,' indicating that changing the implementation language was not previously practical. He said the main reason for deciding to migrate was to prevent the types of bugs that frequently occurred in Bun at compile time thanks to Rust's memory safety, and because they prioritized long-term maintainability and development efficiency.

According to Sumner, Bun has 535,496 lines of Zig code, so rewriting it in another language would take even a small team of engineers a full year. During that time, bug fixes, security fixes, and feature development would be frozen, so Sumner said that 'a complete rewrite of the codebase is historically the worst idea.'

Sumner then spent a week testing whether he could rewrite Bun in Rust using a pre-release version of Claude Fable 5. He didn't expect it to work at first, but after a few days, most of the test suite began passing, and it turned out that the new Rust code was quite similar to the original Zig codebase. Ultimately, he succeeded in rewriting Bun in Rust by using the AI coding assistance tool Claude Code to run approximately 50 different workflows continuously for 11 days, reviewing and correcting the AI-generated transformation results along the way. Sumner said, 'This would have taken a year even for a team of engineers who knew the entire codebase intimately. But with just one engineer using Claude Fable 5 and closely monitoring Claude Code, we achieved 100% pass rate on all platforms in just 11 days.'



Andrew Kelly, the creator of Zig, also shared his thoughts on Bun's complete migration from Zig to Rust on his blog. According to Kelly, the programming style found in Bun's codebase was a hack-on-hack, abuse of makeshift assertions, and, above all, a reckless rush to add features one after another with little time spent on retrospectives, bug fixes, or addressing technical debt, which terrified the Zig team. Therefore, Kelly said he was 'relieved' when Anthropic acquired Bun, and 'overjoyed' when the rewrite to Rust was announced. Kelly then pointed out that the problem lay with Bun, stating, 'The Bun blog suggests that they were diligently fuzzing the Zig code, but when we spoke to the Bun team on the phone, they said they weren't fuzzing anything.'

Meanwhile, when Kelly's blog post became a topic of discussion on Hacker News, Sumner stepped in to refute it . Sumner provided links to relevant code as evidence that fuzzing tests were indeed being conducted continuously, and asserted that 'the claim that 'the developer of Bun spoke to Kelly on the phone and said that no fuzzing tests were being conducted' is completely untrue.'

Bun will continue to be developed based on the Rust version, and Bun v1.4 will provide the development team with powerful tools that will be very useful for improving stability in the future, in addition to making Bun faster, lighter, and reducing memory usage. This case study shows how the migration of a codebase to another programming language was accomplished in just 11 days using AI coding assistance tools, and Sumner said, 'An engineer can do so much more today than they could a year ago.'

in AI,   Software, Posted by log1e_dh