Top
Best
New

Posted by tomlockwood 10 hours ago

How is the Bun Rewrite in Rust going?(lockwood.dev)
396 points | 299 commentspage 2
CrzyLngPwd 8 hours ago|
Just a couple more 100hr weeks of debugging, and the last 80% will be done :-)
germandiago 8 hours ago|
For me this is how all workflows with AI end up lookingif you really want robust products. Do whatever with AI, go fast (from the point of view of perception, initially) BUT it is not going to work without extra work.

and ho, the bloat, do not forget the bloat, which is technical debt towards the future.

I am not anti-ai per-se, but I consider the software I write as a prouct to add features to and maintain over time. So in this case I think it is not wise to say that bc you got something impressive fast you are done. Now you have bugs, architecture, bloat removal, and others...

Letting an AI manage all the workflow is a recipe for disaster in anything that is not strictly short-term. For this reason, I hardly code one-off scripts myself anymore and I hardly use AI for big things besides discussions with the prompt, reviews and snippets. For adding tests it can also be useful.

For full, long-term products, they try to sell agents, and tokens and the like. I think they do not work well enough what I tried. It always ends up as a bloated unmantainable mess.

Unless something that is totally autonomous (by this I mean 100% autonomous) and automated ever exists, I see writing software that can be maintained by humans still critical. As long as this exists, the productivity upper bound will be that of humans reviewing and driving the workflow, even if with AI support.

orsenthil 2 hours ago||
I think, we all are phrasing this wrong. Bun was <strike>rewritten</strike> retooled in Rust by AI with only ensuring integration tests and usage tests succeed. That's similar how to a C program was compiled to binary or Typescript was transpiled to Javascript and run. We didn't make a very big deal of it then, and I think, we should see this operation as a similar higher level source to source translation, which machines have been doing.

Writing code is a different thing.

rootnod3 2 hours ago|
Transpiling and a LLM hallucinating some code that _somehow_ passes the tests is not really the same thing though.
reliabilityguy 9 hours ago||
Many repeat the point of “$165k is cheaper than team of multiple engineers working on the rewrite for a year”, which I think is flawed — the team of engineers would have produced idiomatic rust, and it would take probably 100k+ of tokens more to make the bun in rust idiomatic rust.
asp_hornet 15 minutes ago||
> the team of engineers would have produced idiomatic rust

Not necessarily. Didn’t Microsoft port the TS compiler to Go and they did it by translating the TS? It wasn’t idiomatic Go.

tomjakubowski 32 minutes ago|||
Yes, and curiously many of the tellings of this story don't account for the costs of the human software engineers (Jarred and the other bun team members) who guided all of this work.
furyofantares 9 hours ago|||
They also would have produced a team of engineers that knows the Rust codebase.
busterarm 7 hours ago|||
This is assuming your engineers don't leave for higher-paying roles elsewhere. The market might be cold generally but for engineers working at these frontier AI companies it's red-hot.

And most executives are figuring this into their calculus right now because they were burned badly during COVID. Meta, Google, etc were loose with hiring and engineers flocked from their lower-paying companies in droves. The brain drain was real.

One public company I was at lost nearly 2/3rds of their engineers and mostly to Meta (granted, they had other problems but it was mostly about money -- the offers were excessive). Then market conditions forced them to freeze hiring and they've had a slow exodus of senior talent since as the firefighting has become constant.

AI adoption has only accelerated problems for them.

We've taken this "only two years and then leave" philosophy to an extreme and now companies are totally justified in not investing in their engineers anymore.

ambicapter 7 hours ago||
The job-hopping followed from companies not investing in their engineers, not the other way around. It was billed as the only way to get a promotion (which usually would come every 1-2 years).
busterarm 7 hours ago||
I've been in this industry for a few decades at this point and I was around when this meme was started.

It was purely about maxing your compensation because changing jobs nets you more than promotions & raises.

I've never met an engineer in my life who truly earned a promotion every year and very few every two. Very few companies have org charts that even support that or have that many levels. This logic/advice only really applies at a few companies and people have adopted it no matter where they work. There's not enough growth/hiring at 95% of companies to even come close. The Peter Principle is also a real thing. Everyone's competence has a ceiling.

There's even an implicit understanding of this that people at smaller companies have inflated titles and you typically rank them down 1-2 levels when hiring/acquiring at larger companies.

Now I do agree that companies haven't been investing in their engineers, but that doesn't also mean this isn't a vicious cycle. Employers and employees are in a mexican standoff and things are only going to get worse until one side comes to its senses. Employers have all the leverage for it to not be them.

For the vast majority of companies the average tenure of an engineer sits between 18 and 30 months. They're also mostly hiring young engineers in their 20s. As an employer what is your upside to making such investments before they're at least mid-career? A lot of people seem to want the world and offer nothing in return for it.

swiftcoder 6 hours ago||
> It was purely about maxing your compensation because changing jobs nets you more than promotions & raises.

You don't view it as a problem that companies consistently compensate new hires higher than they are their experienced employees?

Hell, I would have been perfectly happy to never change employers in my entire career to date, if my salary had anywhere near kept pace with my peers who were job-hopping.

busterarm 5 hours ago||
> You don't view it as a problem that companies consistently compensate new hires higher than they are their experienced employees?

It depends on the current employee and the incoming employee. They are not interchangeable cogs. Also not everyone consistently provides good value over their tenure -- a lot tend to work hard early and then for various reasons taper off. It's not necessarily their fault, but companies definitely are aware of this.

Personally I tend to value growth of my skillset over growth of income and that has largely informed my movement. I move when there's no longer interesting work if the compensation is at least fair. I've never been about comparing myself to others -- especially when most of my peers' left the industry after 5-10 years.

swiftcoder 1 hour ago||
> a lot tend to work hard early and then for various reasons taper off

And you don’t think that has anything to do with incentives (or lack thereof)?

> I've never been about comparing myself to others

Doesn’t have to be about comparing oneself to others. More about the cost of living increasing because software engineering salaries are rising around you…

busterarm 41 minutes ago||
> And you don’t think that has anything to do with incentives (or lack thereof)?

No, that's almost never it. It's mostly life circumstances, burnout, frustration with management, etc.

> More about the cost of living increasing because software engineering salaries are rising around you…

We're already talking about very well-paid software engineers here. Appealing to a sense of sympathy over cost of living concerns of 1% earners and them trying to become 0.5% earners isn't exactly a strong argument here...

root_axis 5 hours ago|||
"Knowing the codebase" seems like an antithetical philosophy to LLM driven engineering orgs.
shimman 2 hours ago||
Well the purpose of the tool is to automate more specialized labor so any knowledge that could benefit the worker has to be downplayed or stigmatized.
Tinkeringz 9 hours ago|||
I feel your estimate of tokens is a few orders of magnitude off, it’s on the low side.

I use more (albeit cached) when centering a div.

Hasnep 9 hours ago|||
I think they missed a $ sign, i.e. they meant $100k of tokens
rezonant 9 hours ago||||
This is where we've come to where people proudly proclaim using an AI to do what is a single line of CSS.
d0mine 7 hours ago||
"centering div" is a classic problem (/trauma/meme) that sounds trivial but had no universal solution (until 2017?).
rezonant 4 hours ago||
And has a dead simple one today.

Also worth noting simple horizontal centering of divs was never a problem, margin: auto was defined in CSS Level 1 in 1996 [1].

It was vertical centering that took a very long time to crack, which really became trivial with Flexbox which was first drafted in 2009[2] but became available unprefixed in browsers between 2012 and 2014 [3] about 13 years ago.

[1] https://www.w3.org/TR/REC-CSS1-961217

[2] https://www.w3.org/TR/2009/WD-css3-flexbox-20090723/

[3] https://caniuse.com/flexbox

Subnote: I'm not counting the display: table hacks.

reactordev 9 hours ago||||
100k tokens is your pre-prompt and your CLAUDE.md as well as a few files from your root.
moralestapia 8 hours ago|||
What a great joke.

I will have to steal it for an upcoming AI tools meeting I have at work.

Also, pretty clever as centering a div w/ CSS has been notoriously difficult to achieve.

rcxdude 7 hours ago|||
Would they have, in a year? The general plan of attack would likely still be the same: rewrite it in rust while keeping the structure as similar as possible, no matter how unidiomatic, then adjusting the design to make it more idiomatic to rust. Doing both at once is much harder.
reliabilityguy 3 hours ago||
> Doing both at once is much harder.

I think with sequential approach (translate -> make idiomatic) it is easier. However, I am not sure that monetary difference is going to be as stark as $165k vs 3 engineers/year. Especially, if you consider that no one knows that is what in the code at the end.

Sure, you can argue that now it doesn’t matter — agents and all that, but I am not so sure.

nozzlegear 4 hours ago|||
IMO a team of engineers (presuming this is pre-AI) would have improved the existing Zig codebase, rather than spent time and money on a Rust port in the first place. In fact, I still think most teams of engineers would choose to improve what they have even now, circa AI.
tcfhgj 8 hours ago|||
I doubt file by file rewriting takes as much work as rewriting and refactoring the code - especially at this scale.
witx 6 hours ago|||
Yes this is a typical case of showing results fast. I wonder what the cost for the remaining 10℅ of debugging and fixing all the bloat will be. Not so cheap I am guessing
irishcoffee 9 hours ago||
> produced idiomatic rust

I keep seeing this. What is "un-idiomatic" rust?

TazeTSchnitzel 8 hours ago|||
Rust contains the ability to do everything that C can, if you use `unsafe`. And a file-by-file rewrite in Rust from another language usually involves keeping the ABI and API between files very C-like (and unsafe). In practice this means that the result of a first pass this way has all the memory safety of C code, but with worse readability because Rust makes unsafe things less ergonomic.

To actually get the safety benefits of Rust in a real way you have to rework those files to not treat eachother as C code. This is the interesting and the difficult part of a rewrite in Rust, and one that an unsupervised LLM rewrite is probably not even going to attempt.

I don't think this latter stage has actually happened with Bun's codebase. The result of the Rust rewrite in Bun's case is actually less safe than the Zig it is replacing, especially because (I am told) a lot of the new Rust code is unsound (introducing UB).

insanitybit 5 hours ago|||
> To actually get the safety benefits of Rust in a real way you have to rework those files to not treat eachother as C code. This is the interesting and the difficult part of a rewrite in Rust, and one that an unsupervised LLM rewrite is probably not even going to attempt.

You can use deterministic linting for `unsafe` usage, have agents target `unsafe`, etc. It's pretty easy. You can even run `miri` against the code and give that as a tool for LLM feedback. I've done this all before and it works fine.

> The result of the Rust rewrite in Bun's case is actually less safe than the Zig it is replacing, especially because (I am told) a lot of the new Rust code is unsound (introducing UB).

I'm unconvinced that this is true. How could you tell? You only know about the rust bugs because rust makes them grep'able/ trivial to verify, there's no way of knowing which bugs existed in zig that didn't translate. Regardless, the problem is now trivial to understand in Rust and start to target.

skeledrew 7 hours ago|||
> one that an unsupervised LLM rewrite is probably not even going to attempt.

Why not? A complete test suite exists, so it just boils down to "reimplement this code to reduce the number of 'unsafe' references, while keeping the tests passing" (the last part isn't even needed since Claude loves to run tests and linters anyway).

TazeTSchnitzel 5 hours ago||
An LLM definitely can do that work, but LLMs have a tendency to follow the path of least resistance unless you force them to do things properly and carefully supervise them.
skeledrew 5 hours ago||
> LLMs have a tendency to follow the path of least resistance

That's a really strong motivation for the Rust port. It's literally impossible to take a path not leading to an unacceptable outcome because the Rust compiler fails the compile if code no longer marked "unsafe" is still actually unsafe, and the tests fail if the implementation is incorrect. The compiler actively helps to force the LLM to do things properly.

TazeTSchnitzel 1 hour ago||
…only if you actually force the LLM not to use `unsafe` somehow! And one must remember that `unsafe` can have all sorts of non-local effects. One way to be maliciously compliant (or in the LLM's case, I guess it's more incompetence than malice) is to make a “safe” function that does an `unsafe` operation for you, and then replace every usage of that unsafe operation with your “safe” function. You can remove hundreds of unsafe blocks that way without any improvement in safety.
vessenes 9 hours ago||||
Presumably lots of stuff wrapped in 'unsafe'. I'm not a rust guy or a rust fan, and the last time I wrote something with Rust was like 7 years ago, but to my memory, because of how Rust manages mutability there are many access patterns that are Rust-specific; idiomatic Rust is going to use this patterns but they would be unlikely to show up in a language with a different type system / borrow checker / etc. etc.
irishcoffee 9 hours ago||
So "unidiomatic" rust means, 'don't use these parts of the language even though they're first-class citizens?'

How odd. Lot of mental gymnastics going on there.

flohofwoe 8 hours ago|||
The Bun author himself writes that the port is not idiomatic Rust:

    Do the rewrite that looks like we transpiled our Zig code to Rust. We can gradually refactor it to reduce unsafe usage and look more like idiomatic Rust after Bun v1.4 ships.
(from: https://bun.com/blog/bun-in-rust)

The original version of Bun was already a line-by-line (manual) port of esbuild from Go to Zig (also mentioned in this post), so the Zig code already wasn't "Zig-idiomatic" and apparently riddled with problems. That doesn't inspire much confidence in the LLM-translated Rust version tbh.

skeledrew 7 hours ago||
> That doesn't inspire much confidence in the LLM-translated Rust version tbh.

And yet Claude Code, which is the primary consumer, continues to chug away without any issue (that I, as a fairly heavy user, have encountered).

williamdclt 7 hours ago||||
> "unidiomatic" rust means, 'don't use these parts of the language even though they're first-class citizens?'

that is indeed a roughly accurate definition of what "unidiomatic" means

tribaal 8 hours ago||||
It's mostly the same in any general purpose programming language though, parts of the language features are meant (or became seens as) tools to be used in very narrow cases, which people less familiar with the language tend to "overuse".

Eg. goto/jump, bare "except" statements in python, etc... In Rust, unsafe has its uses and is a first class language feature, but it certainly isn't idiomatic to use it to mimic access patterns from other languages (unless absolutely necessary).

ModernMech 8 hours ago||||
It means "don't misuse parts of the language in ways that circumvent best practices" one of which is "keep unsafe regions as small and few as possible" not "never use unsafe"
vessenes 8 hours ago|||
Meh. The (a major?) goal of Rust is this sort of type safety flowing down to memory bugs. Not every possible access pattern was known at the beginning, and generally they developed a philosophy of keeping the "unsafe" memory access patterns extremely bounded and heavily inspected. I think that's a fair and admirable goal.
throwaway613746 4 hours ago|||
[dead]
rao-v 2 hours ago||
I don't quite understand the focus on the token cost of this rewrite. Obviously, we should examine if this rewrite is good, effective, good for the product etc., but the token cost seems ... not important?

The marketing value of this to Anthropic (if Anthropic even cares, this might just be the Bun team selling past the close) is to show that such a rewrite is possible and delivers engineering value. If exactly this project is $800K today, it'll be $200K and then $80K soon, so it's not so important to the story that it's cheap, just that a big "cool" rewrite is possible, and delivers velocity to the buisness.

lawn 2 hours ago|
I'd say it's an important data point if you'd want to do something similar yourself.
smb06 2 hours ago||
I do believe they were trying to use CodeRabbit to review their re-written code. https://www.coderabbit.ai/blog/ai-can-migrate-your-entire-co...
coderdatapoint 2 hours ago||
I just got a github notification on an old Bun bug report when it was still coded in zig. The bun-bot had completely solved the bug in the new rust codebase, added comprehensive tests, did the write up, pushed the commit all without human interaction. The fix looked sound and changed minimal lines of code. This AI is the real deal. Programmers should be concerned.
podgorniy 8 hours ago||
> I hadn’t seen the numbers for the CI/CD costs of Buildkite, and as you might have noticed from above, some PRs were written by Anthropic employees.

The leaked code of the claude had switch flag where claude pretends to be employee. You can't trust/expect that those PR's were authored by people.

germandiago 8 hours ago|
> some PRs were written by Anthropic employees

Oh, that company that I heard did not use humans aymore to write software and bragged about it? I heard, correct me if I am wrong.

Something does not match here...

muglug 9 hours ago||
This post doesn’t make sense. It was rewritten in Rust. The rewrite itself is complete (no more Zig).

Various people have claimed that Bun in Zig had a lot of tech debt. If they’re to be believed, it seems natural to assume the rewrite does, too. Perhaps all this activity is paying down some of that debt.

pizza234 8 hours ago||
> This post doesn’t make sense

The author's assumption is that a rewrite is not just a mechanical translation of code - it's also a state of stability. And no release, for the author (I agree) means no stability.

It's like a developer who says that after a week of work, a feature is 90% ready, but the other 10% is still not ready (for release) after months.

virajk_31 9 hours ago|||
Author kept "going" in title because there has been no minor/major release in last two months which unusual for this project if you review the older releases.
muglug 9 hours ago||
A major rewrite in another language is also unusual for this project.

It took TypeScript a year to go from announcing tsgo to releasing TypeScript 7.0. That work was done in parallel; here the work is being done serially — and it’s likely to take much less than a year for a new release.

chmod775 8 hours ago|||
> It took TypeScript a year to go from announcing tsgo to releasing TypeScript 7.0.

These are not comparable at all. The bun "rewrite" really is more of a translation of a software that is mainly dogfooded, created with an at best loose regard for a wider ecosystem.

TypeScript 7.0. by comparison is not just a translation from one language to another. It's a true rewrite that at the same time has to consider a massive existing ecosystem (which needs to catch up first or you risk fragmenting it). Plus you might as well consider 6.x part of the effort, since that was the stepping-stone.

Also where bun really is just a runtime implemented with a bunch of glue code plus supporting tooling, TypeScript is much more complex. Change one part of TypeScript and you can get cascading issues somewhere else in the compiler easily. Change something in Bun and you'll likely just break some discrete part.

dminik 5 hours ago|||
It's funny, but a large reason for why Go was chosen was explicitly because it has semantics close to TypeScript and that made it automatable:

https://github.com/microsoft/typescript-go/discussions/411#d...

> But this wasn't a compiler redesign, and the TypeScript to Go move was far more automatable and more one-to-one in its mapping.

So basically the opposite of what you're saying.

skeledrew 7 hours ago||||
> The bun "rewrite" really is more of a translation of a software that is mainly dogfooded, created with an at best loose regard for a wider ecosystem.

This seems self-contradictory. If it's just a translation, doesn't that mean it remains fully compatible with that wider ecosystem? All the existing APIs retain identical behavior given the preexisting comprehensive test suite that had to go 100% green after all.

chmod775 6 hours ago||
> This seems self-contradictory.

It's not.

Passing an existing test suite just moves the optimistic lower bound to incidental compatibility, it doesn't move it to intentional - "regard" implies you gave it thought.

Plus, it's not just about code: it's also about giving the ecosystem a migration path. Dumping 500k LOC on people and discontinuing development of the zig version effective immediately (there hasn't been a release since and the zig tree is only a reference - the build script is removed afaik) is the opposite of what TypeScript did. If you broke someone's N-API module because of a regression not caught by your suite they're now between a rock and a hard place.

The good news is that there's nobody there to notice. The bun userbase is miniscule* compared to TypeScript's.

* negligible? irrelevant? laughably small? I'm struggling to find an adjective that does the difference justice.

skeledrew 3 hours ago||
That "incidental compatibility" point is a good place to start. Unless there are serious gaps in the test suite, one can have high confidence that there's no regression from the pre-fork version in documented behavior.

What kind of migration path beyond 0 regression do you think is needed? And if the latest Zig version is no longer available, how were at least 2 forks based on it submitted to HN? And what kind of release are you expecting when the team is working to fully migrate to the port (so far it's still marked canary)? If someone's using an untested (ie. very likely unpublished) API, well it sucks to be them but they should know the risks.

And again the self-contradictory argumentation. If the userbase is as miniscule as you imagine then your criticisms are essentially meaningless. No ecosystem worth giving a migration path and nobody's N-API module breaking because of a regression, right?

TiredOfLife 5 hours ago|||
TypeScript 7.0 was literally a line by line translation. With essential features necessary for adoption still like a year off.
virajk_31 8 hours ago|||
Yes, its because Anthropic took over and wanted to showcase their LLM capabilities by porting such a complex codebas.
taormina 8 hours ago||
Everyone’s point is “they have everything to gain by lying about being more done then they are” and “the claims seem at least a bit full of shit”.
rk06 9 hours ago|||
bun in zig was used by many companies. some were using it in prod. how many of those are using it in prod? none, because bun in rust is not released yet.

Hence, the author concludes that rust rewrite is not complete as bun in rust is not released yet.

I agree with author's POV.

davidgtonge 9 hours ago||
The rust version is being used by Claude Code though - which is a fairly large product!

I was hoping for more push back against https://bun.com/blog/bun-in-rust - which is pretty thorough and has some decent arguments and reasoning for why they did the rewrite.

reactordev 9 hours ago|||
I think they meant “released and available for use” rather than just out in the wild.
thevinter 8 hours ago||
It is available for use: `bun upgrade --canary`
strobe 3 hours ago||
it doesn't imply that lot legacy apps won't crash in prod when it will be actually released. Cool that some complex app is working but is nothing proving that everything will be fine when everyone will try to upgrade.
flohofwoe 8 hours ago||||
How much of the Bun/Node API surface does Claude Code actually use though? Conceptually it's a relatively simple TUI application.
nullsanity 9 hours ago|||
Yeah, but it's a TUI that has more bugs and worse performance than any other TUI in history. It's not like we'd notice a user after free.
Aurornis 7 hours ago|||
> Various people have claimed that Bun in Zig had a lot of tech debt. If they’re to be believed,

This is one of the funnier takes on the rewrite. Bun was held up as a flagship Zig project for years. Then they chose to rewrite in Rust and everyone up to the Zig author has suddenly switched to claiming that Bun was terrible code all along.

IsTom 7 hours ago||
If what they're claiming is true then what were they supposed to do? Go "Hey guys, it's the biggest project in Zig and it sucks, don't look at it"? Not exactly a good PR move.
abalashov 9 hours ago|||
> Perhaps all this activity is paying down some of that debt.

Perhaps. But were that the case, one would think they'd be quite eager to say so.

muglug 9 hours ago||
Maybe they will!

Are you expecting them to live-tweet their work or something?

abalashov 8 hours ago|||
Based on the way they live-tweeted (as it were) their rewrite and their other publicity stunts? Yes, actually.
tough 9 hours ago|||
jared was OK making this rewrite as an experiment branch in the public

why shouldnt upcoming work be as public as the rewrite itself was?

skeledrew 7 hours ago||
You may continue to hold your breath. You may die as a result. The maintainers continue to do what they want regardless.
cowl 9 hours ago||
tech dept is not a problem. to paraphrase captain Jack sparrow. "even if it were the most indepted working software project, IT WORKED". On the other side of the medal we have a rewritten software that although it's trumpeted for it's rewrite speed, it is not showing the same Release speed as the manualy written, "tech dept ridden" old one.
pianopatrick 3 hours ago||
At what point should I trust projects like this?

I've heard stories of LLMs changing tests to get all the tests to pass instead of actually fixing code. So I'm not sure I trust it just because tests pass. I also think that tests do not and cannot check everything.

I also don't trust it just because it compiles in Rust. The Rust compiler does not check everything.

So at what point do projects like this cross from "untrusted" to "trusted"?

simonw 3 hours ago|
> I've heard stories of LLMs changing tests to get all the tests to pass instead of actually fixing code.

That's very easy to prevent. Don't let them edit the tests! Run the test suite against a reserved copy.

pianopatrick 3 hours ago||
That makes sense to me as a tactic to prevent that problem.

But the article talks about how so much code was written so fast. Seems to me that to create that much code that fast you have to have AI produce both the code and the tests.

So I am not sure in this project if the AI can edit the tests or not. I assume that because this is Anthropic the AI is doing as much as possible, which would include editing tests.

simonw 24 minutes ago||
Bun had an enormous existing test suite written in TypeScript. Getting those tests to pass against the Rust version was the key thing that enabled the project.

You can go and check if the AI edited the tests yourself: look at the git history of those files in the public Bun repository.

amazingamazing 9 hours ago|
Why did they buy an open source project anyway? If is not “officially” supported why not fork and use? Claude code is probably the most used anyway
jeltz 9 hours ago||
They bought the maintainers, not the code.
amazingamazing 8 hours ago||
Why though? Isn't AI supposed to take care of such things?
atonse 6 hours ago||
Because even when the AI is really good at writing code, you still have to know what to ask it, how to direct it, have product taste, etc.

Otherwise all of us would just be able to build bun via a prompt.

quikoa 9 hours ago|||
To me it just looks like a marketing stunt.
More comments...