Remix.run Logo
Philpax 6 hours ago

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%.

simonw 4 hours ago | parent | next [-]

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.

einsteinx2 3 hours ago | parent | next [-]

> 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.

cognitiveinline 5 minutes ago | parent [-]

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.

malisper 4 hours ago | parent | prev | next [-]

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.

nvader 2 hours ago | parent | next [-]

I hope that you're going to call it PostGrust.

xeromal 43 minutes ago | parent | prev [-]

Would love to follow your journey!

Philpax 4 hours ago | parent | prev [-]

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.

bielok 6 hours ago | parent | prev | next [-]

I would guess that people looking to use Zig understand that those are project concerns and not language concerns.

Zakis1 6 hours ago | parent [-]

The stability gains are a direct language concern as mentioned throughout the article.

throwaway27448 5 hours ago | parent | prev | next [-]

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.

pdpi 5 hours ago | parent | next [-]

A sophisticated rewrite? Sure. This was a naive like-for-like rewrite, though.

17 minutes ago | parent | prev [-]
[deleted]
h14h 4 hours ago | parent | prev | next [-]

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.

frollogaston 5 hours ago | parent | prev | next [-]

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.

lifthrasiir 5 hours ago | parent | prev | next [-]

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.

saghm 5 hours ago | parent [-]

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)?

lifthrasiir 5 hours ago | parent [-]

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.

saghm 4 hours ago | parent [-]

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.

geon 5 hours ago | parent | prev | next [-]

Wouldn't the same improvements have been made in zig if they instructed the agents to improve instead of rewrite?

gpm 4 hours ago | parent | next [-]

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".

Zakis1 5 hours ago | parent | prev [-]

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.

pyrolistical 6 hours ago | parent | prev | next [-]

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

kgeist 5 hours ago | parent | next [-]

>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.

kvuj 3 hours ago | parent [-]

But how can it be a mechanical rewrite if the tool used isn't deterministic?

kgeist 3 hours ago | parent [-]

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

lifthrasiir 5 hours ago | parent | prev | next [-]

The article explicitly mentions the maintainability as a foremost concern.

silver_silver 5 hours ago | parent [-]

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.

lifthrasiir 5 hours ago | parent | next [-]

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...

silver_silver 5 hours ago | parent [-]

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.

teach 5 hours ago | parent | next [-]

You're entitled to call things as you wish, of course, but your definition of "vibe-coding" differs quite a bit from mine.

frollogaston 4 hours ago | parent | prev [-]

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.

27183 4 hours ago | parent [-]

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.

simonw 2 hours ago | parent [-]

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.

daishi55 4 hours ago | parent | prev | next [-]

> 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?

fragmede 4 hours ago | parent [-]

Claude code is buggy and they don't appear to be maintaining it just fine.

daishi55 4 hours ago | parent [-]

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.

cozzyd 4 hours ago | parent [-]

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...

Klonoar 3 hours ago | parent | prev [-]

> 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.

baby 4 hours ago | parent | prev [-]

I find Rust more readable than zig

linzhangrun 3 hours ago | parent | prev | next [-]

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.

rq1 5 hours ago | parent | prev | next [-]

From a PL Theory perspective, Zig is vibe-coded.

Not sure why people use it.

benced 3 hours ago | parent | prev [-]

The scary thing is the zig project prohibits LLM contributions - the world is going to move faster than them.

AlotOfReading an hour ago | parent [-]

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.