Bun's Rust rewrite has been merged
81 points
by ale
1 hour ago
| 20 comments
| old.reddit.com
| HN
vitaminCPP
59 minutes ago
[-]
> +1009257 -4024

Bun is now over 1M lines of Rust code.

This is approaching the size of the Rust compiler itself; except that BunJs is mostly a JavaScript interpreter wrapper + a reimplementation of the NodeJS library (Rust STD wrapper).

I think BunJS is becoming the canary for software complexity management in the LLM era.

reply
sunrunner
19 minutes ago
[-]
I'm not sure if it's just the leading '+' or if there are other factors for phone number detection on iOS, but on mobile the line count changes are underlined and I can tap it to start a call, which, if it is because of the diff size, is something I find pretty amusing.
reply
nesarkvechnep
13 minutes ago
[-]
Maybe it's the phone number of the vibe coding police?
reply
embedding-shape
36 minutes ago
[-]
> I think BunJS is becoming the canary for software complexity management in the LLM era.

Yeah, Cursor did the same thing, bragging about how many lines of code they managed to produce for a semi-working browser, completely missing the idea where less code is better, not the other way around.

reply
anuramat
3 minutes ago
[-]
I think their point was that the project is complex, with the implicit assumption that the complexity is to a large degree inherent.

Even if it's mostly accidental, and the code is overengineered slop (which it is), the system being able to decompose a problem and deliver something is impressive in terms of stability: it wasn't sucked into rewriting everything from scratch every time it would run into issues, it didn't have infinite subagent recursion with a one-agent-per-line type workflow, etc.

reply
gm678
1 hour ago
[-]

    $ rg 'unsafe [{]' src/ | wc -l
    10428
    $ rg 'unsafe [{]' src/ -l | wc -l
    736
    
    Language        Files     Lines      Code  Comments    Blanks
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    Rust             1443    929213    732281    116293     80639
    Zig              1298    711112    574563     59118     77431
    TypeScript       2604    654684    510464     82254     61966
    JavaScript       4370    364928    293211     36108     35609
    C                 111    305123    205875     79077     20171
    C++               586    262475    217111     19004     26360
    C Header          779    100979     57715     29459     13805
reply
ordu
37 minutes ago
[-]
The half of the files contain 'unsafe' keyword? It doesn't seem as a good rewrite. What is the point of rewrite into Rust, if ~half of your code is still unsafe?
reply
fbernier
24 minutes ago
[-]
Bun is fundamentally a boundary-heavy system and it also rolls its own version of a lot of things that people typically use via libraries, where unsafe is hidden. (no async, memory arenas, etc). It also uses FFI heavily which requires unsafe.

It also looks like the top 2 maintainers are currently actively working on getting the amount of unsafe down and it's going down quickly.

reply
_aavaa_
25 minutes ago
[-]
1. Rewrite from zig to rust in as close to zig as you can.

2. Turn into idiomatic rust.

reply
embedding-shape
35 minutes ago
[-]
Some correct me if I'm wrong, but it's unlikely they wrote this first initial version of Rust and will leave it unchanged as-is. What's there now is a step in a long process, not the final destination.
reply
tayo42
34 minutes ago
[-]
Rust has a ton of other features besides safe. Like exhaustive checking of enum variants and the ability to avoid using null with option and result.
reply
petcat
18 minutes ago
[-]
Cool you can just search specifically for potentially unsafe code in Rust. How do you search for unsafe code in Zig? Or do you just have to assume it's everywhere?
reply
Robdel12
43 minutes ago
[-]
Sure hope Mythos is as world beating as they claim, they’re gonna need it now.
reply
vitaminCPP
49 minutes ago
[-]
We got memory safety at home !

At home:

> 10428

reply
therepanic
1 hour ago
[-]
About 9 days ago, Jarred wrote that it was far from certain that this would merge and that it was an overreaction. Ironic.
reply
noosphr
1 hour ago
[-]
When you don't own your company any more anything you say can be safely ignored. It was obvious that the token spend will need to be justified.
reply
simlevesque
58 minutes ago
[-]
They've been shady since day one, claiming wild performance improvement compared to their competitors and never proving any of them.
reply
rcxdude
9 minutes ago
[-]
I mean, that doesn't exclude the outcome that it gets merged.
reply
simlevesque
1 hour ago
[-]
[flagged]
reply
dang
26 minutes ago
[-]
You've crossed into personal attack with this, and that's not allowed here. Please don't.

https://news.ycombinator.com/newsguidelines.html

reply
gib444
9 minutes ago
[-]
Which persons were attacked by their comment? The "them" is confusing me – I interpreted it as Bun the organisation / Anthropic?
reply
Yeroc
57 minutes ago
[-]
I think Jarred's response at the time was intended to cool the ridiculous hype when the branch first appeared!
reply
losvedir
44 minutes ago
[-]
Wow. This is going to be interesting to follow. There's absolutely no way any of this code was reviewed, but maybe we're in a post-human world now where you can trust the models to write and review the code. This is like Gastown but on a higher profile project. Will be fascinating to see how this project is able to add new features going forward (or even _if_ it will be able to).

Does anyone know how exactly Bun is used by Anthropic? Is it a part of Claude Code? I'm more than slightly worried about using Bun going forward myself, but I'm not sure to what extent that applies to using Claude as well.

reply
torben-friis
18 minutes ago
[-]
Does anyone know how exactly Bun is used by Anthropic? Is it a part of Claude Code?

It seems to be used by anthropic as a way to shift the discussion window into it being acceptable that you yolomerge millions of lines.

reply
darknoon
11 minutes ago
[-]
the `claude` binary is essentially a packed copy of bun + the js code, so this will replace the native runtime part of claude code.
reply
rafram
32 minutes ago
[-]
> you can trust the models to write and review the code

You definitely cannot!

reply
operatingthetan
28 minutes ago
[-]
Reminds me of going on linkedin and seeing all these sales and product people who are talking big game about engineering now. Well yeah they are definitely producing something but not sure I'd call it "engineering."
reply
gmueckl
20 minutes ago
[-]
You can trust them to flag some things during review that may or may not be relevant. But just like with human review and unit testing, you cannot guarantee the absence of bugs after an LLM code review. It's just another set of (virtual) eyeballs.
reply
weraK10
51 minutes ago
[-]
As an educational thread, see this one from a week ago where Jarred again deflects from a merge decision and legions of foot soldiers attack anyone who predicted the impending merge:

https://news.ycombinator.com/item?id=48073680

Didn't age well, did it?

reply
dgellow
6 minutes ago
[-]
If the bun team is around I would be interested to get their opinion on this: in the old time migrating a 1M codebase from one language to another meant you would pretty much become an expert in the target language. The output of the work is team experience/knowledge + the actual rewrite. With that Bun rewrite do you feel that the Bun team learned something other than “Claude can rewrite a very large codebase in no time”, which is impressive in itself. Is the output only the rewrite, or did you learn something along the way? And how do you feel about your answer? Not a snark question, like a lot of others I’m myself trying to understand how I feel about how our profession is/has been changing.
reply
alfanick
52 minutes ago
[-]
I'm confused. Never heard of Bun until a few days ago here on HN. It's some nodejs wrapper thingy, written in Zig, and someone decided to use LLM to rewrite it in Rust. Is this a big deal? Who is even using this software? Why is this big?
reply
tshaddox
44 minutes ago
[-]
Bun isn't a node.js wrapper. It's an alternative to node.js that sits at roughly the same spot in the stack.

Node.js is a distribution of the V8 JavaScript engine (the thing that executes JavaScript in the Chrome browser), along with a bunch of standard library code written mostly in C++.

Bun is a distribution of the JavaScriptCore engine (the thing that executes JavaScript in the Safari browser), along with a bunch of standard library code written mostly in Zig (and now Rust). Bun's standard library is in many cases compatible with or inspired by the Node.js standard library, but with some changes for convenience and performance.

reply
konart
48 minutes ago
[-]
Rust vs Zig "wars" etc.

Also at some point Bun was acquired by Anthropic. And some people feared that this will greatly influence Bun's development.

reply
binary132
45 minutes ago
[-]
which was obviously a reasonable reaction.
reply
hxtk
43 minutes ago
[-]
I think relatively few people are probably running Bun in production, but as a dependency management system and bundler for the JavaScript ecosystem, it's similar to `uv` from the Python ecosystem in how much faster it is compared to the most popular alternatives so it's fairly popular in that space.
reply
mgrandl
25 minutes ago
[-]
PNPM is just as fast and much more reliable.
reply
jesse_dot_id
45 minutes ago
[-]
Not mature enough for everyone to be using it yet, but it may dominate the space down the line. They compete with Deno.
reply
applfanboysbgon
46 minutes ago
[-]
Bun is not a node.js wrapper, it is a node.js alternative. It had non-trivial adoption, tens of thousands of stars on github for whatever that's worth (before the AI spam took over stars). It was then purchased by Anthropic and now we're witnessing open source software that people used be sacrificed to the altar of LLM marketing hype.
reply
yoyohello13
44 minutes ago
[-]
Bun has a lot of buzz as 'the next big thing' in the JS ecosystem, and was recently purchased by Anthropic. So it's kind of in the zeitgeist.
reply
darthShadow
1 hour ago
[-]
reply
christophilus
1 hour ago
[-]
Well, that escalated quickly. I think I first heard rumors of this a week or two ago. That's a very vast turnaround for such massive code-churn. I don't know how to feel about this.
reply
ibejoeb
58 minutes ago
[-]
Github is failing to load the 800 comments, naturally. I'll bet they're fun.
reply
xigoi
5 minutes ago
[-]
Too bad modern computers are not capable of processing 800 paragraphs of text. That’s several hundred kilobytes! Maybe the technology will advance thanks to AI…
reply
pixelesque
10 minutes ago
[-]
6,755 commits for the PR as well...
reply
Imustaskforhelp
50 minutes ago
[-]
Github actually made my computer lag when there were no comments at all because of the 1 million lines of code added iirc. I could've responded something first but well I wanted to say something meaningful and didn't have anything so I just closed it.

I had to literally force quit my browser because of how much it lagged iirc.

reply
linkregister
1 hour ago
[-]
reply
makotech221
46 minutes ago
[-]
first major company to really nuke their main product via AI psychosis?
reply
nesarkvechnep
8 minutes ago
[-]
The average quality of the Zig projects got up.
reply
LucidLynx
43 minutes ago
[-]
Is this really the state of "software engineering" today? :/
reply
gmueckl
17 minutes ago
[-]
That's what the new AI overlords want the world to believe, at least.
reply
sudb
44 minutes ago
[-]
If this means that segfaults become rarer with Bun I might consider using it in production again. As it stands, Bun has been great as an all-in-one TS/JS package manager, build system and test runner but unstable enough that I still want Node running in production backends.
reply
xigoi
3 minutes ago
[-]
Surely there are no bugs in the 1000000 lines of code that no one has reviewed…
reply
sisve
29 minutes ago
[-]
Yes. That is the plan.

See jared comment [0]

If this helps bun and rust is a better lang for developing bun going forward with the help of claude. Then i think that is just find.

I thought rust was making the codebase complex so zig won on speed and dx.

But with llm and a large codebase it seems like rust gives fewer bug and you can develop it faster & safer.

https://news.ycombinator.com/reply?id=48133519&goto=threads%...

reply
atonse
59 minutes ago
[-]
I have full faith, it's the same really smart people that built bun (Jarred and team) that have spearheaded this and are running it. So I have no reason to believe that this was done carelessly.

That said, I'm still shocked and amazed that something this big is possible these days. But as we've seen multiple times now, one of the most important things your codebase can have is a solid test suite.

I will continue to use bun, because at the end of the day, it isn't just the technology, but the talent/people behind the technology that ensures that it will be solid.

And since that hasn't changed, I will still trust bun and its direction.

Also, bun is mostly glue code and sort of "user space" libraries (my words) as Jarred has said on X, most of the underlying runtimes like JavascriptCore, etc weren't rewritten.

So this isn't like 100% of what we think of as bun was rewritten. It's more like the scaffolding and harness.

reply
ifwinterco
37 minutes ago
[-]
Just because it's possible, doesn't mean that it's sensible
reply
bigstrat2003
16 minutes ago
[-]
> So I have no reason to believe that this was done carelessly.

Writing software with an LLM is doing it carelessly.

reply
moomoo11
42 minutes ago
[-]
yeah but it also made some tests pass by changing the tests. i’m not super familiar so i’ll dig more on weekend but it seems sus pending more review. i’ve had ai do similar things that i caught in manual review. cheating the test is bad.
reply
gmueckl
13 minutes ago
[-]
It is welk known that agents can cheat or go off on tangents and not recover. Just recently deleted a bunch of code files that I didn't ask for. The code wasn't even used anywhere.
reply
elwesties
24 minutes ago
[-]
This is so awesome! What a time to be alive that something like this is possible.
reply
ChrisArchitect
45 minutes ago
[-]
reply
kracket
1 hour ago
[-]
It's going to be absolute mess of total AI slop and black box that nobody understands and is going to cause more issues than it fixes.
reply
vitaminCPP
46 minutes ago
[-]
Yep. How will we manage those 10x code projects, when LLMs cost increases by 10x?
reply
philipbjorge
42 minutes ago
[-]
I've done some pretty incredible things with LLMs. If this were sqlite with its exhaustive test suite... OK, I can see it.

It's hard for me to see this not becoming a pile of slop, but hey, maybe I'm wrong

reply
jauntywundrkind
1 hour ago
[-]
What does this mean for bun add-ons like opencode's opentui? Did FFI also somehow get ported or will that have to be updated? https://github.com/anomalyco/opentui
reply