Bun (the js runtime) is being vibe-ported from zig to rust
28 points by pscanf
28 points by pscanf
This is nuts. Looking at the "Idiom map", it's absolutely littered with unsafe and is going to produce a ton of non-idiomatic Rust code. The mapping for @fieldParentPtr("field", ptr) is particularly wild. Although I guess this "phase A" is just about the (basically) line-for-line translation, and they will attempt to prompt-refactor into more idiomatic and maintainable Rust. The issue is, of course, language design can and does push implementations into a particular direction, and there will be some gnarly things to unravel. I suspect to the point where a good ol' fashioned rewrite would have been the better path.
Making it idiomatic and safe can probably be done in a following step by the LLM. The convenient feature of IAs, especially when you have the funding of Anthropic, is that they're not getting tired of refactoring the same code.
Exactly. It's like eating your broccolis first.
Manual or automated, first massage the original code into a portable shape. Remove as much "magic" as possible.
Then port the code as is to a new framework, new language version, or even a new language. Ideally, file and line accurate to be able to quickly refer to the source material in case of doubt.
Find the mismatches between the src and dst set of hidden WTFs, and iron those out. Make the tests green, run some shadow prod traffic, fuzz it, what have you.
Now, you're in a safe place to cast it into the shape you've originally wanted and started the whole process for 😋
TypeScript native port is a great example.
Apart from the migration itself, I find the approach that they're taking particularly interesting.
The docs/PORTING.md file I've linked to contains a set of ~300 rules for the port, which I would think is way too many for any LLM to "keep in mind" and follow faithfully. Since Anthropic owns Bun, they probably have an infinite token budget for this port, so maybe they can spawn number of files * number of rules agents to "ensure" they're all followed.
Also, they're splitting the port into two phases: A -> crudely port each file in isolation, expect compilation to be broken; B -> wire everything up so it compiles. For phase A, they're telling the agent that the code "does not need to compile", and to score each ported file with low/medium/high according to the output quality (low = logic is wrong; medium = logic is right but doesn't compile; high = logic is right and should compile).¹
This is the opposite of how I understand and use coding agents, so I'm curious to see how it plays out. (In my mind, telling the agent that the code does not need to compile, and thus not giving it a clear "end goal", would yield very unpredictable results, and would leave me in phase B having to review a mountain of code that I have no confidence in.)
¹ Running a quick grep, out of 1279 such output-quality scores ~3% are low, ~80% are medium, and ~17% are high.
300 rules seems ok to me at the time of writing in May 2026. That PORTING.md is ~16k tokens, and they focus on the primary task. Not too bad, and probably ideal for a fresh subagent.
In the sense that a single model has that much attention budget? I actually never tried to push the limits to see how many "things at the same time" a model could pay attention to, but my intuition would have given a figure one order of magnitude lower.
Do they actually want to transition to Rust or is this a test of Anthropic's LLMs?
The conspiracy theorist inside of me says they are doing this because of Zig's recent ban on AI assisted contributions and Mattew Lugg's roast of Bun's fork of the language. It would be a big flex from Anthropic to move Bun, one of the most popular projects in Zig, away to another language in such vulgar display of power.
I don't fully believe myself in this drama-fuelled theory and it might be just Anthropic deep pockets trying to showcase their products.
If I were to guess they want to test the waters of what a Rust version of Bun might look like. Since they are now owned by anthropic they have tokens to spend and it might make exploring an alternative path viable. I doubt this has anything to do with Zig's stance on AI contributions.
I will however say that as someone who is using agents to program both Rust and Zig, I find it significantly easier to get an agent to work well on a Rust codebase than a Zig codebase and it makes me wonder if that is a related motivation.
Remember the kind of people in charge of these companies. My money is on your first bet. "You are breaking up with me? Not if I'm breaking up with you first!"
The regular pull requests for bun are wild too: https://github.com/oven-sh/bun/pulls?q=is%3Apr+
Most are created autonomously by @robobun, checked for duplicates with a GitHub action (powered by Claude), reviewed by @coderabbitai and @claude. Meanwhile the CI is broken and @robobun finally closes a portion of its own PRs because they duplicate other PRs it has written. (Merging into main is still done by a human.)
Oh, I did not expect this. I remember Bun being praised for Jarred's "obsession" with perfs. I wouldn't have thought they'd let LLMs run wild on the codebase.
One of his biggest obsessions for a while has been LLMs and maximizing his usage of them, as far as I can see. It 100% tracks with his interests, and it tracks with his views on open source development.
Looks real interesting.
The only issue I see is that the set of rules to handle at once is impossible to verify without hammering the output through a ton of code review cycles. I get it, they've got tokens, but after such a transformation it's going to be virtually impossible to verify the code. Tests have to go through the same, so what's left from the ground truth then?
Still, an amazing experiment by all means. Good luck!
For what it's worth, here's what Jarred Sumner said on HN about this:
I work on Bun and this is my branch
This whole thread is an overreaction. 302 comments about code that does not work. We haven’t committed to rewriting. There’s a very high chance all this code gets thrown out completely.
I’m curious to see what a working version of this looks, what it feels like, how it performs and if/how hard it’d be to get it to pass Bun’s test suite and be maintainable. I’d like to be able to compare a viable Rust version and a Zig version side by side.