Bun is being ported from Zig to Rust
- Jarred - 15061 sekunder sedanI 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.
- stingraycharles - 37151 sekunder sedanInteresting to see this when the current top post on HN is someone worrying about Bun as it was acquired by Anthropic. The top comment there describes “Anthropic does experiments on their own codebase, the Bun team is not gonna do the same vibe coding experiments”.
Yet here we are, what looks like a massive undertaking for vibe coding.
Time will tell how this will turn out. Would be nice if the Bun maintainers could give some clarification about what they’re doing here, and why they’re doing this.
- kgeist - 34281 sekunder sedanInteresting how times have changed. Back in 2015, the entire Go runtime (already a mature codebase) was rewritten from C to Go semi-automatically: one of the maintainers wrote a C-to-Go conversion tool (for a subset of C they used) so that it compiled and produced identical output, and then the resulting code was manually refactored to make the Go code more idiomatic and optimized. And now you can just ask a language model.
The slides: https://go.dev/talks/2015/gogo.slide#3
An interesting similarity:
>We had our own C compiler just to compile the runtime.
The Bun team maintain their own fork of Zig too
- hsaliak - 33414 sekunder sedanThe problem with vibe coded re-writes is that you basically sign off on understanding the generated codebase at that point. Any historical knowledge of the codebase is gone.
- archargelod - 34679 sekunder sedanLinked commit is probably not the most convincing for this tagline. Here's a branch[0] of Claude mass rewriting Zig code into Rust which is currently at 773,950 additions and 151 deletions:
[0]: https://github.com/oven-sh/bun/compare/claude/phase-a-port
- tacitusarc - 32757 sekunder sedanI wonder if a successful, albeit slower, approach would be to walk the git commit history in lockstep, applying the behavioral intent behind each commit. If they did this, I would be interested in knowing if they were able to skip certain bug fix commits because the Rust implementation sidestepped the problem.
- selectnull - 17036 sekunder sedanWhy not rewrite claude-code in Rust?
So, Anthropic acquires Bun team because claude-code uses Bun. They port Bun from Zig to Rust presumably because Rust "is better" (imagine big air quotes here). Again presumably, they want to make claude-code "better". Why make it so complicated? With all the power of LLMs they have, surely they can make claude-code the best possible by writting it in Rust directly.
- carpenecopinum - 16503 sekunder sedanGiven the recent gripe that Bun/Anthropic indicated regarding compile times with Zig (i.e. that their vibe-coded 4x compilation speedup PR wasn't accepted), it appears to me as an "interesting" move to switch to a language that probably delivers 4x longer compilations than even vanilla Zig.
- jr-14 - 35526 sekunder sedanI want zig to succeed but given that zig is not yet 1.x I'd imagine a large code base like bun would have difficulties addressing major breaking changes. Also given the fact that bun is using a fork of zig https://x.com/bunjavascript/status/2048427636414923250?s=20
- padjo - 21845 sekunder sedanPicking a pre 1.0 language to build your product always seemed like a bad choice to me. Purely on that basis and ignoring the recent drama this seems like a reasonable idea for tech debt pay down to me. Assuming automated conversion can work without making things worse, which is not exactly a given.
- Humphrey - 36610 sekunder sedanI'll be very interested in how this AI port turns out. I am involved in a number of active projects that are being held back by the language / framework is holding back the project, but where a rewrite would be too big of a project to undertake by using only human power.
I've had more success vibe coding Rust than I have in more dynamic languages. I suspect the strictness of the Rust compiler forces the AI agent to produce better code. Not sure. It could be just that I am less familiar with Rust so it feels like it's doing a better job.
- yladiz - 37344 sekunder sedanWhy? Are there particular reasons that the maintainers of Bun feel the need to attempt to migrate from Zig to Rust?
- croemer - 16332 sekunder sedanAt this point, it looks just like an experiment. It's not a definitive "were going to switch".
I think people here are reading too much into it.
- inkysigma - 37269 sekunder sedanSo I can't tell if the linked commit is an actual attempt or just an experiment but it did always strike me as odd to make a JS runtime in Zig when my impression was there were a lot of work-stopping compiler bugs at the time.
- hbbio - 34872 sekunder sedanGiven they have "unlimited" AI usage, do we expect the port to be complete tomorrow?
- elffjs - 35389 sekunder sedanComparing this claude/phase-a-port branch with main: “Showing 1,646 changed files with 773,950 additions and 151 deletions.”
- thayne - 34687 sekunder sedanWhen I first heard that bun was written in zig, I thought that was an odd choice for such a large project, mostly because the language is "unstable" and is still making significant breaking changes.
I would guess dealing with breaking changes is a big motivation for this.
- wg0 - 29686 sekunder sedanIf nothing, it'll be good marketing material targeted at non-technical enterprise executives so that they pressurize their engineering teams in meetings that look people are porting such complicated things from one different language to totally different language then why are we not using AI effectively?!
- cropcirclbureau - 33257 sekunder sedanThe only Bun shipped product I've used in anger is OpenCode and I regularly run into segfaults on it. I doubt this is the reason for migration but every time it happens, it reminds me the real cost of unsafe code. That being said, Zig is an absolute pleasure to write and I can't wait until it has a real library ecosystem, Rust's greatest boon.
- mohsen1 - 9487 sekunder sedanI am also porting TypeScript to Rust. With a different design I managed to make it faster than tsgo port. I've made a lot of progress in the last 4 months but needs more work. Contributions are welcome!
- toledocavani - 32954 sekunder sedanFor better or for worse, at least Bun is open source, and the world is not lacking a NodeJS alternative.
What is the most interesting here for me is:
- a big, clear outcome and acceptance criteria, vibe coding project on
- a public, working, high performance, full featured, production codebase by
- the leading LLM model maker known for the strongest coding ability
A good example no matter if it successes or not.
- classicposter - 31191 sekunder sedanhttps://github.com/oven-sh/bun/issues/30197
It seems there was an issue where the image API ignored the ICC Profile.(now fixed) Any developer with experience implementing image formats would almost certainly avoid this mistake. This is a problem that cannot be solved with vibe coding. In this situation, the user is merely a guinea pig for bug fixes.
- - 15497 sekunder sedan
- jvidalv - 14720 sekunder sedanBun can't be used for anything serious, only as a "script kiddie" to run small scripts.
Trying to run it as a replacement for node in persistent backend/api scenarios is just plain broken.
RSS grows unbounded under Bun: https://discord.com/channels/876711213126520882/148058965798...
- rollulus - 19742 sekunder sedanRewriting it using an LLM is one. But did all the contributors became as proficient in Rust as they were in Zig over night as well?
- bijowo1676 - 24650 sekunder sedanIts never been easier to rewrite X in Rust than today.
Will everything eventually be rewritten in Rust and we finally achieve utopia?
- ozgrakkurt - 8759 sekunder sedanJust checking some loc numbers from nodejs, bun and deno:
On nodejs: `tokei src`: 98333 LOC C++ Code
On bun: `tokei src` 573572 LOC Zig Code
On deno: `tokei libs cli runtime` 289573 LOC Rust Code
This seems wrong though so would be appreciated if someone who knows the structure of these projects can correct me on the folder names.
Doing `tokei lib src test deps` gives more than 5M loc. but not sure if that is fair
- heldrida - 37401 sekunder sedanI suspect that an experiment is being run. In any case, that'll be a hell of a story!
- anymouse123456 - 33303 sekunder sedanThis is a huge loss for the zig language and community.
As a fan of the language, I hope it leads to some reflection on things that might need to change moving forward.
- - 10466 sekunder sedan
- thatxliner - 28947 sekunder sedanDidn't they write a whole blog post on why they chose Zig over Rust?
- apatheticonion - 24033 sekunder sedanHaving written a JavaScript runtime in Rust in the past - Rust is an excellent choice. Not just due to the development experience, but also for embedders who want to consume the project as a a library (rather than a binary, e.g. node).
Not sure about vibe-coding it. While they aren't using v8, LLMs made it easier to understand v8 quirks and update v8 as they make weird changes every now and then. It couldn't write the runtime without help though.
For those curious: https://github.com/alshdavid/ion
- arthurcolle - 35343 sekunder sedanCould just be an experiment or something. It's Monday, the week is young
- classicposter - 30369 sekunder sedanhttps://x.com/bunjavascript/status/1966806250827714736
Haha, is it really okay not to retract that that the official account previously posted a caricature criticizing Rust?
- asG1298 - 3666 sekunder sedanI mean this is self-evident. Bun got bought by Anthropic to shill in the open source space:
https://bun.com/blog/bun-joins-anthropic
"I got obsessed with Claude Code"
So the bad, bad Zig that opposes the clanker mania has to be punished, even if top comments deny it.
Anthropic is one of the most evil companies in existence today. Whenever someone produces something, they steal it.
- holysantamaria - 15666 sekunder sedanMaybe Mythos told them to quit using zig because it is not safe
- davidtranjs - 26169 sekunder sedanthis isn't vibe coding. this is vibe rewriting. ~500k lines of code. nobody is reading those diffs line by line. nobody.
- born-jre - 14298 sekunder sedanLet the guy cook, would be nice benchmark of llm nothing else. Damn I wish I had access to infinite tokens for crazy experiments like this.
- ngoquocdat - 28186 sekunder sedanI think they are simply experimenting to fully exploit Claude's models' powerful capabilities.
- notnullorvoid - 32577 sekunder sedanProbably a good thing for the project even if the only net positive ends up being the Bun team stops maintaining a fork of Zig.
- nananana9 - 17187 sekunder sedanAlright, back to node.
I was hopeful for this project, and I've reported crashes & bugs in the bundler with the hope that it will stabilize over time, but this is just silly - I'm not going to risk them pulling the rug under me and replacing the runtime with 1 million lines of vibecoded rust.
- ratstew - 34092 sekunder sedanThis feels more like a reaction to Zig's anti-LLM policy than anything. Anthropic would probably like to contribute something back to Zig at some point, but I doubt anyone would ever believe their PRs were not written by Claude.
- kadhirvelm - 16396 sekunder sedanI can't imagine going from reviewing code in Zig to letting Claude code handle it in Rust. Seems like a lot of change to deal with in a short amount of time. Wonder how much the bun team culture will change? We've been really liking bun so far
- kandros - 16617 sekunder sedanUnexpected, I was waiting for them to maintain a zig fork
- simultsop - 27540 sekunder sedanWhich makes one think, why they did not buy deno at first place then?
If they did, I guess they would rewrite deno in C++
- icase - 28002 sekunder sedanoh for christ’s sake
- confessinator - 32846 sekunder sedanAside from Zig's anti-AI stance and maintaining their own Zig fork, I think this port will showcase that Anthropic can re-engineer a massive codebase.
As an aside, I've been bitten by Zig's breaking changes on my own projects as well. It's taken the shine off of Zig and I'm looking at alternatives.
- shevy-java - 6094 sekunder sedanPoor Zig - it's bleeding now.
Everyone wants to be a Rustee these days.
- _pdp_ - 15046 sekunder sedanClaude Mythos cannot do the porting?
- - 33829 sekunder sedan
- larpa - 36832 sekunder sedan"Claude, migrate bun to Rust, make no mistakes"
- root_axis - 33718 sekunder sedanAny confirmation that a genuine port is underway? This might just be an experiment.
- ivolimmen - 26916 sekunder sedanI am not a fan of AI but my limited experience with running local small LLM's did show me that rewriting some scripts into a different language worked really well. So my guess is this will just turn out fine.
- joknoll - 22708 sekunder sedanmaybe anthropic should‘ve just acquired deno
- Animats - 30162 sekunder sedanHow well does that long translation prompt work?
- hiroakiaizawa - 21671 sekunder sedanInteresting. What are the main trade-offs they expect from the switch?
- forrestthewoods - 30771 sekunder sedanI hope they ship and use this. It’ll be a super interesting case study in a few years.
- iamgopal - 27593 sekunder sedanthe days are not far when golang will be ported to rust.
- GianFabien - 25691 sekunder sedanHere we go again ...
Company A buys company B. A's management decrees the henceforth B's aqcuihired team must comply with company A's standards.
Second system effect kicks in. Bugs multiply.
Half of original company B devs leave.
I'm investigating whether future projects should revert to using Deno.
- gib444 - 23012 sekunder sedan> Read this whole document before writing any code.
Hm does that actually work?
Edit: in a way that can be verified, and not the AI tool saying it did
- Capricorn2481 - 31174 sekunder sedanApril 26th - Bun announces they used AI to fork Zig so they could make an optimization for a 4x improvement
April 27th - Zig contributor mlugg clarifies why the specific optimizations Bun did were ill advised and wouldn't have been accepted in Zig, regardless of AI use [1]
May 4 - Bun is looking into Rust as an alternative.
This, to me, seems like total whiplash. Has anyone at Bun made a statement on why they're making such dramatic changes? It seems like the lesson to internalize from mlugg is not "switch to Rust"
[1] https://lobste.rs/s/ifcyr1/contributor_poker_zig_s_ai_ban#c_...
- booleandilemma - 34483 sekunder sedanInteresting. When I thought of Zig, I thought of Bun. In my mind it was the flagship application for that language. Is there another? I wonder how the Zig team feels about this. To me it seems like Rust has definitively won now.
- - 36589 sekunder sedan
- sergiotapia - 35357 sekunder sedan>*No `tokio`, `rayon`, `hyper`, `async-trait`, `futures`.* No `std::fs`,
I'm not a rust dev but even I kind of notice that tokio is kind of shunned in most projects. Why is that? Is it just bad or what?
- ConanRus - 36756 sekunder sedaninstead of writing it once in C++
- matrix12 - 29487 sekunder sedanit will make it more portable.
- markovmodel - 21585 sekunder sedanwhat a win
- insumanth - 2340 sekunder sedan[dead]
- lacymorrow - 16846 sekunder sedan[dead]
- noborutakahashi - 4279 sekunder sedan[dead]
- Amber-chen - 32161 sekunder sedan[dead]
- y534y5 - 32076 sekunder sedan[dead]
- nothinkjustai - 35145 sekunder sedanMakes sense on merit. There really isn’t room for Zig when Rust exists, is more ergonomic, and also safe.
- altun - 16541 sekunder sedanI guess it's like Trump saying, "I'll take Greenland too..."
- 0x142857 - 36826 sekunder sedanyou can use both zig and rust in a single project, duh
- hakrgrl - 30131 sekunder sedanPeople are asking why they would switch from zig to rust. I wonder the opposite: why would anyone would use zig over rust?
- Entambi - 34101 sekunder sedanhahaha eat your heart out "don't port it to rust" gang
- AbuAssar - 27531 sekunder sedanI fully support this decision
Nördnytt! 🤓