Live data from Hacker News

Claude Code uses Bun written in Rust now

simonwillison.net

781–790 of 920 posts

Re: Claude Code uses Bun written in Rust now

#781

Drilling into the original article where Jarred explained the reasoning behind the change, It's pretty clear that under zig the team was doing things by hand that are automatic in rust. Humans and agents share one thing: they are both non-deterministic. He talks about the issue of tracking memory lifecycles manually in zig so it can be explicitly freed. As expected, this leads to a long list of bugs where people miss…

> He talks about the issue of tracking memory lifecycles manually in zig so it can be explicitly freed. As expected, this leads to a long list of bugs where people missed things. Yes, and again the "you're holding it wrong" people or "you are not a good enough developer" people will try to do juggling with a chainsaw and lose a couple of fingers in the process Claude Code's endorsement (and real-world testing) speaks…

[deleted]

Re: Claude Code uses Bun written in Rust now

#782
post #670

Earlier quoted context omitted.

"Fun fact", it lets you largely circumvent the borrow checker by creating arbitrary lifetimes: https://news.ycombinator.com/item?id=48974824

People are so funny about rust. “Safe rust isn’t expressive enough!” -> then use unsafe rust. “Unsafe rust lets you do anything! Even crazy things!” -> then use safe rust. Or just don’t write crazy code? Does bun actually do anything insane like that in its unsafe blocks? Or are you just fear mongering?

Please try to interpret comments in the context of the discussion, not floating freely in a vacuum. The context of the discussion is the Bun port's excessive use of unreviewed unsafe blocks. unsafe in Rust can easily be misused to create Undefined Behavior, which renders any safety guarantees otherwise ensured by Rust's borrow checker invalid.

> Does bun actually do anything insane like that in its unsafe blocks?

Who knows? At 10k unreviewed uses of unsafe, I'd guess there are quite a few incorrect ones. LLMs don't produce perfect code (neither do humans), so there's a high probability that at least some of those create UB.

Re: Claude Code uses Bun written in Rust now

#783
post #505

Earlier quoted context omitted.

Is that before or after the earths atmosphere acidifies for humans and our bodies can’t hold enough phosphorus or calcium for basic metabolic tasks? You have until 2050: https://doi.org/10.1007/s11869-026-01918-5

these doom and gloom reports also said half the land will be under water by now and average temperature will be 40c. Didn't happen. Earth is in a cooler period and it will get very warm. These crappy climate change activists will not get anything done but to hold us back. We need more power, more tech, and more abundance of things. We will need to engineer our way out of real climate change.

Don’t look up - or that hubris might crush you.

Re: Claude Code uses Bun written in Rust now

#784
post #723
post #712

Earlier quoted context omitted.

What's the point of using Rust in the first place when you disable the compiler feature that protects you the most?

Mu. Invalid question. Rust doesn't disable compiler features. It gives you extra set of footguns when you ask for it. As for the actual unloaded question, "What's the point of unsafe in Rust?" it is to contain and make it easier to identify sources of UB.

The whole point of the rust rewrite is that bun is now thought to rely on rust’s memory safety features, but that assumption doesn’t hold if everything’s inside an unsafe block.

Re: Claude Code uses Bun written in Rust now

#785
post #376

Earlier quoted context omitted.

Zig (like C) is simply not a good language to use if you're going to do many small allocations with uncorrelated lifetimes. To write robust Zig (or C) code, you must manage lifetimes yourself, for example by grouping allocations on an arena or by having fixed buffers of "things". You can just do that, and then Zig is really no less robust than Rust. But if you want to do "managed language" style allocation patterns (…

> You can just do that, and then Zig is really no less robust than Rust. If you just don't write bugs, then yes all languages are equally robust, including assembly. Zig, like C, is simply not a robust language. I don't know why this feels like something contentious? It's clearly not intended to be robust?

Realistically much of the most reliable software in the world was written in C. Robustness is more so a function of coding style and engineering practice than it is of the programming language chosen.

Of course you could argue that on average, most programmers are not going to have the right practices and skill, so on average you should prefer Rust. But that's unrelated to the argument I was making, and in any case not a very interesting point in my opinion.

Re: Claude Code uses Bun written in Rust now

#786
post #714

Earlier quoted context omitted.

Borrow-checking the dereference of a stale pointer won't be worth much, though.

Sure; but I bet raw pointers are used very infrequently in the new codebase. The code was ported from zig to rust. I bet a lot of pointers became rust references in the process.

That’s my whole point! It’s ported to unsafe rust, not default rust.

Re: Claude Code uses Bun written in Rust now

#787
post #724

Earlier quoted context omitted.

People tried to "just do that" (write their programs in a memory safe way) in C and other languages with manual memory management for decades, and we have countless vulnerabilities that prove this simply doesn't work. That's why newer languages, with the notable exception of Zig, prefer more advanced memory management methods.

> People tried to "just do that" (write their programs in a memory safe way) in C and other languages with manual memory management for decades, and we have countless vulnerabilities that prove this simply doesn't work. Who are these "people" you speak of? It's possible to write software in low level languages that don't have these problems. Not a "non-zero" it might be possible, it can be done thoughtfully, and the…

Yes, it's possible. It's also possible for experienced pilots to fly an airliner completely manually for the full duration of a transatlantic flight without crashing. Still, over the last decades, autopilots and other assistance systems with ever more sophisticated features have been developed, and I would argue that without this technology crashes would be much more frequent than they are today. Same goes for memory management: you can do it manually, and it might work out most of the time, but if the programming language is helping you with it, the likelihood of memory safety issues decreases drastically. And the problem with avoiding these issues only by "meeting certain standards of rigour" is that you might only find out that you have failed to meet them years later, when you learn that your software has a vulnerability.

Re: Claude Code uses Bun written in Rust now

#788
post #785

Earlier quoted context omitted.

> You can just do that, and then Zig is really no less robust than Rust. If you just don't write bugs, then yes all languages are equally robust, including assembly. Zig, like C, is simply not a robust language. I don't know why this feels like something contentious? It's clearly not intended to be robust?

Realistically much of the most reliable software in the world was written in C. Robustness is more so a function of coding style and engineering practice than it is of the programming language chosen. Of course you could argue that on average, most programmers are not going to have the right practices and skill, so on average you should prefer Rust. But that's unrelated to the argument I was making, and in any case n…

Adding that with a principled approach, I don't even see much of an issue with doing manual creates and deletes in a object-graph type app, with many unstructured lifetimes. Sometimes that might just be required, and then the complexity is just there either way. Having to cleanups manually or not doesn't change anything about that. It's a bit more cumbersome to get everything right when doing it manually -- sure.

The problem is mostly people graduating from school thinking that somehow there is only stack and heap, and malloc/free is how you do heap. That view completely ignores that the essence of programming systems is mostly to understand the machine, and then doing conceptual and architectural work on a solution (and also on a problem). The act of writing actual code is then mostly just translating those concepts into the digital world verbatim.

Re: Claude Code uses Bun written in Rust now

#789
post #686

Earlier quoted context omitted.

> If you are depending on some behavior not covered in the regression tests, how do you know the next minor release won't break you? Decades of intrinsic knowledge. Which a rewrite lacks. imho the issue is the language used. AI rewrites are cheap and cheap exercises require a great deal of scrutiny and proof of correctness. Simply using regressions test lacks the intrinsic knowledge of a decades old codebase stuck in…

>> Decades of intrinsic knowledge. Which a rewrite lacks. You mean the ones encoded in the regression suite? I think your argument is valid in many medium-to-faang firms where the application is going to have encoded business logic that isn't explicitly tested for. If anything, projects like PG are the exact opposite: no business context and regression suites that test every possible scenario due to the accumulation…

> no business context and regression suites that test every possible scenario due to the accumulation of bug fixes and context over many years.

Spend time enough with a codebase and you’ll know stuff about its behavior that is not encoded in a test suite. Especially when you need to adjust an integration tests due to the modification of an invariant in a dependency.

> How do you know every release of PG doesn't break in the setting of "a year in a sufficiently large system"?

Because the postgres team is professional and will take care of publishing a changelog for what has been modified since the last version.

Re: Claude Code uses Bun written in Rust now

#790
post #724

Earlier quoted context omitted.

People tried to "just do that" (write their programs in a memory safe way) in C and other languages with manual memory management for decades, and we have countless vulnerabilities that prove this simply doesn't work. That's why newer languages, with the notable exception of Zig, prefer more advanced memory management methods.

> People tried to "just do that" (write their programs in a memory safe way) in C and other languages with manual memory management for decades, and we have countless vulnerabilities that prove this simply doesn't work. Who are these "people" you speak of? It's possible to write software in low level languages that don't have these problems. Not a "non-zero" it might be possible, it can be done thoughtfully, and the…

Just people like the linux kernel, all major browsers, most of our popular webservers, etc and basically all non-trivial software projects written in C.

The good news here is that we have more than just anecdotes to support this, we have empirical evidence.

Post reply on HN