Live data from Hacker News

Claude Code uses Bun written in Rust now

simonwillison.net

731–740 of 920 posts

Re: Claude Code uses Bun written in Rust now

#731

Earlier quoted context omitted.

Bun was not ported to Rust for performance reasons and its not clear to me how anyone can think it was. The reason they've given is memory safety.

Plus 1) There's much more reusable open source code written in Rust than in Zig 2) There are more Rust developers than Zig developers.

I don't think there being more rust developers should matter if we're talking about a company that solved coding.

Re: Claude Code uses Bun written in Rust now

#733

Earlier quoted context omitted.

Relevant passage from Jarred's post: "At the time of writing, about 4% of Bun's Rust code sits inside an unsafe block (~13,000 unsafe keywords across ~27,000 lines / ~780,000 lines), and 78% of those blocks are a single line — a pointer that came from C++, or one call into a C library. I expect this number to go down over time as we refactor from a faithful Zig port (which had no greppable unsafe keyword) to idiomati…

Relative "number of unsafe keywords" or "lines inside unsafe blocks" isn't a good metric. It's unsafe to call a C library that gives you a raw pointer, that can be a single line. It's unsafe to use that pointer, that could be a second single line. Carrying that pointer around, the data structures it's in, that's all safe, and doesn't implicate lifetime checking at all, so Rust will let you do silly things with the ac…

Yeah, one needs to understand that "unsafe" does not mark which parts of the code are actually unsafe, it simply marks parts where the compiler ignores parts of its rule set. But the implications can crop up anywhere, there is no guarantee that a resulting use-after-free or similar can only happen inside the unsafe blocks.

In short, if you use an unsafe block, then potentially any part of your code is unsafe.

Re: Claude Code uses Bun written in Rust now

#734

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…

I seem to recall this Rust rewrite is all "unsafe" meaning it really doesn't automatically eliminate those issues.

what is surprising about it? The way porting works has alway been first doing a faithful pass before going back to address impedance mismatches case by case. You would do that even when porting things manually, let alone in a super risky completely automated bulk migration.

Re: Claude Code uses Bun written in Rust now

#735

Earlier quoted context omitted.

> The "General Labor Substitute": He rejects the idea that his employment forecasts are "doom marketing". Instead, he asserts that AI will act as a general substitute for human labor, noting that most software engineering could be entirely automated within 1 to 2 years When someone says all Software engg could be automated within 1yr they don't mean 'oh use our agents and keep human in loop' They mean 'AI superior th…

News flash: most of software engineering is already automated. When was the last time you wrote code? They did not claim there is no human involved.

[deleted]

Re: Claude Code uses Bun written in Rust now

#736
post #714
post #654

Earlier quoted context omitted.

Unsafe Rust doesn't automagically disable typesystem (& borrow checker, but lifetime are a sort of types). Once raw pointer is turned into a T, &T or &mut T, the borrow checker is on.

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.

Re: Claude Code uses Bun written in Rust now

#737
post #273

Earlier quoted context omitted.

They succeeded in spite of their tech choices. Their model outshone it, which is an extremely rare thing to happen and not something they could've counted on. In any other timeline they could've/would've been hurt by their choices. It's like "why did you go all in on buying scamcoin 3.0 as your investment strategy?" -- "I 5xed my money! End of story! It was fine!"

> They succeeded in spite of their tech choices. Or those choices just don't matter, it's fundamentally just "tabs vs spaces".

The choices were clearly (far) less important than having the best model and a good product that was way ahead of the competition.

However, that's not the same as the technology choices not mattering at all. As others have mentioned the product is buggy, and it appears Anthropic are struggling to continue to release new features within the existing architecture.

That's also not to say that Anthropic made bad choices - there's always going to be a tension between building quickly to capture the market now vs moving slower and building something more maintainable in the long-term.

Re: Claude Code uses Bun written in Rust now

#738

Earlier quoted context omitted.

Except that it hasn’t yet hit the real world, the live release is still 1.13.4, the last Zig version. Anthropic does not operate in the real world.

The canary build has been Rust for over a month, available to anyone. In that time it has been used in production for Claude Code and Prisma Compute.

We found the Rust based canary version to solve a number of memory leaks that we were struggling with in the Zig based 1.3. One of our engineers wrote up the details here: https://www.prisma.io/blog/bun-rust-rewrite-prisma-compute

Re: Claude Code uses Bun written in Rust now

#739
post #376

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…

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 (…

[deleted]

Re: Claude Code uses Bun written in Rust now

#740
post #670

Earlier quoted context omitted.

Fun fact, unsafe does not let you turn off the borrow checker in Rust: https://steveklabnik.com/writing/you-can-t-turn-off-the-borr...

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

Post reply on HN