News for hackers. Stuff that matters.
Re:Rewriting Bun in Rust by Philpax on Wednesday July 08, 2026 @06:30PM (#48838232)
Without commenting on Bun itself as a project, or the nature of the rewrite, it can't be good for Zig that a naive rewrite away from it fixed memory leaks, improved stability, shrunk binary size by 20%, and improved performance by 5%.
Re:Rewriting Bun in Rust by simonw on Wednesday July 08, 2026 @08:09PM (#48839185)
I don't think it's care to categorize this as "a naive rewrite away from [Zig]" - Jarred has been immersed in this project for five years, got to benefit from everything he learned along the way and spent $165,000 of tokens on the most advanced coding LLM anyone has access to.

I expect if he'd spent $165,000 running Fable against the Zig version he could have got a 5% performance improvement, too.

Re:Rewriting Bun in Rust by Philpax on Wednesday July 08, 2026 @08:19PM (#48839292)
Oh, I have no doubt that they could have extracted those gains from Zig! My point is more that, from a relatively naive line-to-line port, they were able to claim these benefits without much effort.

It's not great for Zig if you have to put in more work to end up at the same place efficiency-wise, especially for a language marketed at people who like to get the most out of their metal.

Re:Rewriting Bun in Rust by gwenzek on Thursday July 09, 2026 @01:03AM (#48841201)
That's not what the article says though. The size reduction was from extra linker flag for deduping code, and the speed gains from LTO.

They could have done the same in Zig, even though it probably shows cargo is better at this than build.zig.

Re:Rewriting Bun in Rust by malisper on Wednesday July 08, 2026 @08:45PM (#48839487)
I can confirm a naive rewrite won't make things faster. I've been working on rewriting Postgres in Rust. I rewrote things function by function similar to how Jarred did. Even though the new Rust code mapped closely with the previous C code, it was 8x slower. This was due to myriad of reasons. For example naively converting a C union into a Rust enum can be slower because Rust stores a tag with the enum, while C unions do not.

I've been working on a new rewrite that's focused on beating Postgres on performance. As of this morning I got to 100% of the tests passing and have meaningful performance gains over Postgres.

Re:Rewriting Bun in Rust by nvader on Wednesday July 08, 2026 @10:35PM (#48840300)
I hope that you're going to call it PostGrust.
Re:Rewriting Bun in Rust by agumonkey on Thursday July 09, 2026 @03:27AM (#48842158)
Then you'll have postgrest on postgrust
Re:Rewriting Bun in Rust by SwiftyBug on Thursday July 09, 2026 @07:24AM (#48844121)
Na, PostPostgres would be much cooler.
Re:Rewriting Bun in Rust by xeromal on Wednesday July 08, 2026 @11:55PM (#48840799)
Would love to follow your journey!
Re:Rewriting Bun in Rust by malisper on Thursday July 09, 2026 @12:38AM (#48841051)
If you want to follow along, I've been writing about it on my blog (https://malisper.me/) an you can follow the github repo here: https://github.com/malisper/pgrust
Re:Rewriting Bun in Rust by xeromal on Thursday July 09, 2026 @12:47AM (#48841104)
Bookmarked. I love ambitious projects like this. I'll check in!
Re:Rewriting Bun in Rust by egorfine on Thursday July 09, 2026 @04:34AM (#48842721)
I find it curious that people who take other's people product and rewrite in their favorite programming language still name their own creation the name of the original one.

Like, you have now created your own new database engine that happens to be compatible with Postgres. Wouldn't you take an absolute pride in giving it your own name? Why call it "Postgres rewrite in <programming language>"?

Re:Rewriting Bun in Rust by khuey on Thursday July 09, 2026 @06:53AM (#48843840)
If they did the opposite and called it Mygres or whatever people would give them shit for that too.
Re:Rewriting Bun in Rust by psychoslave on Thursday July 09, 2026 @06:16AM (#48843527)
Maybe not everyone is utterly obsessed with vanity and its delusion?
Re:Rewriting Bun in Rust by egorfine on Thursday July 09, 2026 @11:57AM (#48848054)
Then why use someone else's established brand for your toy project?
Re:Rewriting Bun in Rust by psychoslave on Friday July 10, 2026 @01:32AM (#48856074)
If this is still speaking about the Postgres rewrite in Rust, then naming it something like pgrust[1] makes sense for ease of discovery for anyone aware of these technologies.

[1] https://github.com/malisper/pgrust I guess

Re:Rewriting Bun in Rust by einsteinx2 on Wednesday July 08, 2026 @09:26PM (#48839779)
> and spent $165,000 of tokens on the most advanced coding LLM anyone has access to.

After having used 2 full weeks of 20x Max plan tokens on Fable over the weekend (coding all day Saturday and Sunday on a non-trivial project, tasks across full stack, mix of adding features, reviewing code, and fixing bugs), I’m confident if he’d spent $165,000 in Opus tokens the port would have gone more or less just as well (and probably for less than $165,000). Especially so with the system they set up with all the custom workflows, adversarial reviews, extensive test coverage, etc.

But I get your point is probably more about Jarred’s experience level and the high cost than the specific model used other than it being SOTA. I’m just being pedantic and feeling a bit disappointed with Fable’s real world performance after all the hype.

> I expect if he'd spent $165,000 running Fable against the Zig version he could have got a 5% performance improvement, too.

Totally agree and in fact I’m sure it could be done with significantly less cost even if they stuck with Fable instead of Opus which I’m sure could also do it.

Re:Rewriting Bun in Rust by cognitiveinline on Thursday July 09, 2026 @12:33AM (#48841026)
Fable is kind of fantastic on the difficult tasks. if it's something eithe rmodel can do then you can't see the difference. Fable also makes much less mistakes. It's a more relentless, proactive problem solver.
Re:Rewriting Bun in Rust by steve_adams_86 on Thursday July 09, 2026 @03:47AM (#48842305)
I’ve been noticing that it will test hypotheses for evidence frequently. I really like that. With Opus I have to instruct it with a skill to build prototypes, but Fable will do it and do it really well by default. Really nice detail. I’m guessing it’s part of the system prompt, but the higher capability paired with this experimentation lean makes it far better at planning and verifying.
Re:Rewriting Bun in Rust by frollogaston on Wednesday July 08, 2026 @08:04PM (#48839141)
I pay attention when someone makes a hard decision based on a hard-learned lesson. It's like, most who choose to use an ORM just heard of it or want to avoid learning SQL, everyone who removes an ORM learned firsthand horrors.
Re:Rewriting Bun in Rust by lionkor on Thursday July 09, 2026 @02:13AM (#48841638)
The result of this will be that you end up at the highest level of abstraction.

Let me save you time and tell you that C# and it's ecosystem is where you'll be happy.

Re:Rewriting Bun in Rust by aizk on Thursday July 09, 2026 @02:26AM (#48841727)
Funny you mention ORMs, I'm building a project with bun, and just using raw bun sqlite until I feel the app gets too complicated and I need it. AIs are really damn good at SQL, I can just trust them with it, and it keeps the project much lighter. A few years ago this would just sound stupid, but here we are.
Re:Rewriting Bun in Rust by frollogaston on Thursday July 09, 2026 @11:52AM (#48847969)
That's what I always did pre LLM, it was fine
Re:Rewriting Bun in Rust by bielok on Wednesday July 08, 2026 @06:40PM (#48838335)
I would guess that people looking to use Zig understand that those are project concerns and not language concerns.
Re:Rewriting Bun in Rust by Zakis1 on Wednesday July 08, 2026 @07:03PM (#48838540)
The stability gains are a direct language concern as mentioned throughout the article.
Re:Rewriting Bun in Rust by egorfine on Thursday July 09, 2026 @04:36AM (#48842734)
Judging from comments on this article: no.
Re:Rewriting Bun in Rust by pyrolistical on Wednesday July 08, 2026 @07:08PM (#48838582)
Yeah but they turned it into something unreadable. Call it a skill issue if you wish.

I just haven’t found another language that just makes sense. Zig doesn’t hide anything from you

Re:Rewriting Bun in Rust by kgeist on Wednesday July 08, 2026 @07:35PM (#48838851)
>they turned it into something unreadable

Did you compare the code before/after? It's a mechanical line-by-line port, and most of the code is identical to the old version, just with Rust syntax. They have an example in the blog post.

Re:Rewriting Bun in Rust by kvuj on Wednesday July 08, 2026 @09:32PM (#48839820)
But how can it be a mechanical rewrite if the tool used isn't deterministic?
Re:Rewriting Bun in Rust by kgeist on Wednesday July 08, 2026 @09:57PM (#48839996)
It converges to "almost deterministic" on highly predictable outputs (i.e. code) with the right sampling params (say, you only sample the most probable token without randomness/high temperature) and with self-correction loops
Re:Rewriting Bun in Rust by lifthrasiir on Wednesday July 08, 2026 @07:20PM (#48838712)
The article explicitly mentions the maintainability as a foremost concern.
Re:Rewriting Bun in Rust by silver_silver on Wednesday July 08, 2026 @07:42PM (#48838927)
People say a lot of things, especially when they have a vested interest in a positive outcome. Bun has been fully vibe coded into another language. There’s no way in hell it’s maintainable. Go read any analysis of the Claude Code leak for proof.
Re:Rewriting Bun in Rust by lifthrasiir on Wednesday July 08, 2026 @07:47PM (#48838970)
Claude Code is entirely vibe-coded for a long time. Bun isn't. You go read and compare the actual Bun code; it reads reasonably well [1].

[1] For example, as a random sample, https://github.com/oven-sh/bun/blob/bun-v1.3.14/src/css/medi... -> https://github.com/oven-sh/bun/blob/4924862cffbf671792d47c92...

Re:Rewriting Bun in Rust by silver_silver on Wednesday July 08, 2026 @08:02PM (#48839118)
Sure, reasonably well at first glance, but to quote the article:

> I rewrote Bun in Rust using about 50 dynamic workflows in Claude Code run continuously over the course of 11 days.

> Excluding comments, Bun is 535,496 lines of Zig.

> How do you review a PR with +1 million lines added? How do you start to build the confidence needed to responsibly merge large quantities of LLM-authored code? A language-independent test suite with a million assertions, adversarial code review and when something does go wrong, fixing the process that generates the code instead of hand-fixing the code.

That’s vibe coding. This blog post is an ad for Claude, nothing more.

Re:Rewriting Bun in Rust by frollogaston on Wednesday July 08, 2026 @08:11PM (#48839208)
Doesn't look like vibecoding to me. It does look like a Claude ad, but they do have a vested interest in not screwing up Bun now that they own it.
Re:Rewriting Bun in Rust by 27183 on Wednesday July 08, 2026 @08:29PM (#48839376)
What would be the consequence to them if they did screw it up? Screwing up the maintainability of a project, especially a big one, doesn't necessarily have immediate consequences. The fallout could be delayed by a year or more. Also, they have effectively limitless tokens to burn on keeping everything looking OK, and a vested interest in doing so.

I'm not trying to spin up some kind of conspiracy theory here, but I'm not sure to what extent Anthropic does have any vested interest in this project (in fiscal terms at least) because the reputational fallout could be significantly delayed and might just not be big enough to matter.

Re:Rewriting Bun in Rust by simonw on Wednesday July 08, 2026 @10:23PM (#48840209)
Claude Code is the main reason their revenue (ARR) grew from $9bn to ~$47bn in the first half of this year.

That's a very big reason not to screw this up.

Re:Rewriting Bun in Rust by Zetaphor on Thursday July 09, 2026 @01:25AM (#48841324)
It's far less obvious how choosing Bun results in more revenue for Anthropic. Unlike Claude Code, Bun doesn't require you to pay for tokens to use it
Re:Rewriting Bun in Rust by minimaxir on Thursday July 09, 2026 @01:48AM (#48841460)
Bun powers Claude Code. If the rewrite introduced catastrophic bugs, it would cause catastrophic bugs in Claude Code and therefore without exaggeration could cause $billions of lost revenue.
Re:Rewriting Bun in Rust by 27183 on Thursday July 09, 2026 @07:53AM (#48844423)
There clearly aren't catastrophic bugs. The question is whether the artifact is maintainable over time, since clearly there's a massive amount of net new code that was not thoroughly reviewed. Give it a year or so and we'll know. I claim either way, it doesn't really matter to Anthropic--if it's a disaster they might be able to keep it limping along well enough by just throwing tons of tokens at it. The value in this is not the lasting software artifact, it's the marketing of the rewrite. If over time it turns out to be a great success, all the better!
Re:Rewriting Bun in Rust by teach on Wednesday July 08, 2026 @08:07PM (#48839167)
You're entitled to call things as you wish, of course, but your definition of "vibe-coding" differs quite a bit from mine.
Re:Rewriting Bun in Rust by crote on Thursday July 09, 2026 @02:37AM (#48841805)
500k lines in 11 days? With 8-hour working days that's 100 lines per minute. There's no way you're comprehensively reviewing code that quickly.

The code was generated by a LLM, and the output wasn't even read by its user. That's definitely vibe coding.

Re:Rewriting Bun in Rust by usef- on Thursday July 09, 2026 @04:03AM (#48842442)
It's a direct translation without changing the overall code structure or data structures. I do think this process deserves a distinct name from blind whole-of-project vibe coding.

Translation does seem to be a strength of LLMs, and as they said in the post, the code at the function-level all still feels familiar to the team. They've also already moved users to the codebase without anyone noticing; that's a better result than typical vibe coding.

Re:Rewriting Bun in Rust by aizk on Thursday July 09, 2026 @02:27AM (#48841731)
That vibe coded app is generating billions. Does the word "vibe coded" mean anything anymore?
Re:Rewriting Bun in Rust by daishi55 on Wednesday July 08, 2026 @08:10PM (#48839197)
> There’s no way in hell it’s maintainable

This is not an assertion you are qualified to make

> Go read any analysis of the Claude Code leak for proof

You seem to be implying that Claude code is unmaintainable. Yet they appear to be maintaining it just fine. Did I misunderstand your implication?

Re:Rewriting Bun in Rust by fragmede on Wednesday July 08, 2026 @08:21PM (#48839308)
Claude code is buggy and they don't appear to be maintaining it just fine.
Re:Rewriting Bun in Rust by daishi55 on Wednesday July 08, 2026 @08:28PM (#48839364)
I use it all day every day and haven’t noticed any bugs.

And the fact is that they are maintaining it and it is one of the most successful software products of all time and is earning them mountains of cash. By any metric it is a successful product. So obviously whatever they are doing is working.

Re:Rewriting Bun in Rust by cozzyd on Wednesday July 08, 2026 @08:51PM (#48839533)
Powertop tells me claude-cli creates an inordinate amount of wakeups, halving my laptops battery life if I leave it open. For a tui that should be doing nothing when I'm not interacting with it...
Re:Rewriting Bun in Rust by dgan on Thursday July 09, 2026 @02:08AM (#48841597)
You and the parent are arguing over different, orthogonal things. I believe the parent argues over "efficiency"(=being able to achieve a goal for given amount of ressources) while you are replying over "efficacy" (=being able to achieve a goal). Both could be called 'maintainability' and nobody explicitely tells what definition they use, so all the long pointless discussions could be avoided if people agreed on terms
Re:Rewriting Bun in Rust by jdkoeck on Thursday July 09, 2026 @07:24AM (#48844122)
Last time I used it, it was a a flicker fest. Has it been fixed?
Re:Rewriting Bun in Rust by Klonoar on Wednesday July 08, 2026 @09:10PM (#48839660)
> There’s no way in hell it’s maintainable.

They rewrote the entire thing with extensive LLM use.

It is abundantly clear that their idea of maintainable and yours probably don't match up.

It's apparently out there, shipped in the real world, with people saying it's good. I think it's a pretty clear win for them.

Re:Rewriting Bun in Rust by egorfine on Thursday July 09, 2026 @04:40AM (#48842780)
> There’s no way in hell it’s maintainable

There are different definitions of "maintainable". It seems the prevailing culture at Anthropic is to not touch code manually anymore. So for them "maintainable" means the LLM can fix it.

Re:Rewriting Bun in Rust by baby on Wednesday July 08, 2026 @08:39PM (#48839444)
I find Rust more readable than zig
Re:Rewriting Bun in Rust by m00dy on Thursday July 09, 2026 @01:30AM (#48841355)
you're not alone.
Re:Rewriting Bun in Rust by lifthrasiir on Wednesday July 08, 2026 @07:16PM (#48838669)
The same concern applies to every GC language, so it's not necessarily bad for Zig. Bun can have been grown too large for Zig to be effective, while moderately sized projects may still greatly benefit from Zig.
Re:Rewriting Bun in Rust by saghm on Wednesday July 08, 2026 @07:50PM (#48838992)
I thought Zig was supposed to be a C replacement (as in, it doesn't actually provide full safety in the way that Rust or a GC language would)?
Re:Rewriting Bun in Rust by lifthrasiir on Wednesday July 08, 2026 @07:52PM (#48839011)
Oh, yeah that might be confusing. I meant "you can say the same thing for GC language if that's true, which isn't necessarily true, so that must be false".

More precisely speaking: GC languages are said to delay memory problems far beyond the horizon, which is often unreachable throughout the project's history. Zig can be a similar case.

Re:Rewriting Bun in Rust by saghm on Wednesday July 08, 2026 @08:50PM (#48839519)
Ah, I understand now. That said, I still think there's a pretty strong argument that this is a lot worse for Zig than a GC language, because they also give you safety for that overhead (and potentially ergonomics). When a language is trying to operate in the same niche as C with what seems to be an overt attempt to be less cumbersome than Rust even if it makes it less safe, it's a bit concerning to see that even without the safety it seems to have more overhead rather than less. Put another way: it sounds like it might as well just add a GC if it's not going to be competitive on performance.
Re:Rewriting Bun in Rust by throwaway27448 on Wednesday July 08, 2026 @07:13PM (#48838632)
True, but rewrites often allow for this sort of benefit in themselves. It's possible rewriting it in zig would have yielded some of the same improvements.
Re:Rewriting Bun in Rust by pdpi on Wednesday July 08, 2026 @07:18PM (#48838693)
A sophisticated rewrite? Sure. This was a naive like-for-like rewrite, though.
Re:Rewriting Bun in Rust by geon on Wednesday July 08, 2026 @07:17PM (#48838674)
Wouldn't the same improvements have been made in zig if they instructed the agents to improve instead of rewrite?
Re:Rewriting Bun in Rust by gpm on Wednesday July 08, 2026 @08:08PM (#48839180)
Maybe they'd get the same numeric improvements and bug fixes today (or maybe not, or maybe they'd get even more since the LLM isn't spending time rewriting correct code).

But they wouldn't get a change to the structural issues that created the issues in the first place. They'd end up "ke[eping] fixing these kinds of bugs one-off in perpetuity".

Re:Rewriting Bun in Rust by Zakis1 on Wednesday July 08, 2026 @07:34PM (#48838845)
But how would you verify that the agents have written memory safe code? Rust's borrowchecker is a lot faster and actually verifiably safe compared to asking an LLM to fix the safety issues that the Zig version had.
Re:Rewriting Bun in Rust by egorfine on Thursday July 09, 2026 @04:37AM (#48842750)
Unfortunately (and I say this because I hate this whole rust rewrite) no. There is no fixing a third-party garbage collector on top of the non-memory-managed language. Jarred explains in a post what would that Zig look like.
Re:Rewriting Bun in Rust by rq1 on Wednesday July 08, 2026 @07:13PM (#48838643)
From a PL Theory perspective, Zig is vibe-coded.

Not sure why people use it.

Re:Rewriting Bun in Rust by whytevuhuni on Thursday July 09, 2026 @02:09AM (#48841619)
Pretty much everything except Haskell and the like can be considered as such.

That's because closely following PL theory isn't always the right goal for a language. Ergonomics and pragmatism are far more important.

Re:Rewriting Bun in Rust by rq1 on Thursday July 09, 2026 @08:16AM (#48844662)
I wouldn't disaree on the ergonomics: a powerful but unusable tool is... useless!

Though ignoring all the PL lessons for the sake of "pragmatism" is just plain ignorance.

Rust has a quite solid theory backing. Zig has nothing interesting really: it's "vibe coded" by someone who was doing game dev or something like that.

Re:Rewriting Bun in Rust by h14h on Wednesday July 08, 2026 @08:43PM (#48839475)
While it's easy to look at it that way on the surface, from reading the blog post, it sounds like a big part of it may just be the nature of Bun as a project.
Re:Rewriting Bun in Rust by linzhangrun on Wednesday July 08, 2026 @09:13PM (#48839675)
zig has been developing too slowly. it still cannot reach a stable 1.0 (to the point that even vsc autocomplete gets its Hello World wrong), and then it ran headfirst into AI.
Re:Rewriting Bun in Rust by benced on Wednesday July 08, 2026 @09:20PM (#48839732)
The scary thing is the zig project prohibits LLM contributions - the world is going to move faster than them.
Re:Rewriting Bun in Rust by AlotOfReading on Wednesday July 08, 2026 @11:15PM (#48840537)
I would be pissed if my programming language changed as quickly as Claude code does. Languages need to move slowly and carefully, and zig is on the faster end of language development regardless.
Re:Rewriting Bun in Rust by benced on Friday July 10, 2026 @08:09PM (#48867003)
I would be mad if the syntax was constantly changing but I want the internal implementation to be moving as fast as possible while retaining success. I think that rate is higher than what humans alone can do.
Re:Rewriting Bun in Rust by AlotOfReading on Friday July 10, 2026 @09:35PM (#48867657)
That's a monkey's paw desire because nowhere is Hyrum's law more true than programming languages. Alternatively you just end up with something like C++ where no one understands the whole thing.
Re:Rewriting Bun in Rust by ksec on Thursday July 09, 2026 @03:29AM (#48842172)
I hope Zig won't do a hostile reply to this blog post. But some thoughts on Zig's future where a lot of these problems could be fixed or migrated by better tooling and compiler checking.

But a lot of people have been saying this for sometime, Rust and LLM is a great match. A lot of friction of the language were smoothed out by LLM assisted programming.

Re:Rewriting Bun in Rust by netdur on Thursday July 09, 2026 @07:07AM (#48843962)
Zig and Rust solve different problems, Bun got burned by its indiscipline, and Zig’s response was sadly to flood HN with “how to use Zig” articles
Re:Rewriting Bun in Rust by ksec on Thursday July 09, 2026 @03:21PM (#48851084)
I don't want to say I knew it but it did happen. Slightly disappointed.
Re:Rewriting Bun in Rust by zamadatix on Thursday July 09, 2026 @06:38AM (#48843713)
On the other side of the scale, this codebase started in Zig from 5 years ago while the Zig of today is still very much pre-1.0 - still in the middle of things like finishing up moving to a self hosted compiler. Things like binary size, performance, or some of the oddities around drift in the language (like the custom macros vs now built-in language features) in this rewrite are not really as bad as they'd seem if this was a port from a more complete language.

That said, I think the parts around wanting to properly have memory safety guarantees rather than try hard & patch as issues are found is a more serious concern for Zig as those speak more to the design goals than the current implementation. "better safety than C while maintaining C compatibility" may not be a very compelling reason to chose Zig if other languages are able to do that portion better anyways, even ones without a GC.

Re:Rewriting Bun in Rust by NetMageSCW on Thursday July 09, 2026 @03:26PM (#48851174)
“better safety than Zig while losing compatibility with C” doesn’t seem as compelling a story to me.
Re:Rewriting Bun in Rust by xyzsparetimexyz on Thursday July 09, 2026 @07:11AM (#48844007)
No, you don't get it. Zig is a language about having _fun_. Not memory safety and all that crap. That's why unused variables are hardcoded as errors!
Re:Rewriting Bun in Rust by randusername on Thursday July 09, 2026 @08:54AM (#48845094)
I hope this isn't the takeaway!

Zig was the right tool to start, Rust is the right tool to finish.

Making something possible and refining something until it is high security and reliability are different problems. Zig is great, but for a JS runtime, I just don't think that's the best long-term fit.