7/24/2026 at 12:05:54 PM
To me the most interesting fact about this fork is that it has proven that Bun could have had fast builds all along.To be fair, there are caveats still in place today: Zig incremental compilation does not yet support aarch64 and only the linux linker supports binary patching, but it's just a matter of time before all major platforms are conquered.
by kristoff_it
7/24/2026 at 1:02:45 PM
After the all the noise surrounding the forking of the Zig compiler in order to speed up builds, I'm really surprised that this isn't the top comment. The fact that a one-man team achieved 1s build times proves pretty conclusively that slow build times were entirely result of negligent development practices, and that the fork was a complete misallocation of time.by dtj1123
7/24/2026 at 7:54:06 PM
The port was a political decision. It's now the runtime for claude code first and it must align itself in that ecosystem by becoming fully vibe code.by hoppp
7/24/2026 at 2:08:37 PM
I'm pretty sure they forked Zig long before it supported incremental compilation. In fact, it's still experimental and not enabled by default.by IshKebab
7/24/2026 at 1:41:23 PM
A significant part of the port was also for the built-in safety. Unsafe code just... fails to compile.Turns out there's a journey here.
by skeledrew
7/24/2026 at 5:25:19 PM
GP is talking about the fork of the Zig compiler, not the rewrite of Bun into Rust.Anthropic submitted to patch the Zig compiler to improve Bun compilation times, it was rejected. One reason it was rejected is that it contained AI-generated code, which is against the community guidelines, but more importantly, it would have been rejected regardless of AI use. They claimed a 4x improvement, something like going from 2 minutes to 30 seconds, but, according to the Zig team, it made compilation non-deterministic, and missed on the real improvement they worked on, which was sub-1s incremental builds.
"Buz" shows that the fork submitted by Anthropic wasn't needed as Bun can now compile under 1s (incrementally), which is much better than the 30s they achieved with their patch.
It is likely that this rejection, especially the "no AI" aspect of it encouraged Anthropic to move away from Zig.
by GuB-42
7/24/2026 at 5:30:07 PM
Is there anything suggesting that Bun even attempted to submit their Zig patches? As far as I know, they were stuck 2 versions behind. With the amount of changes and Zig already working on incremental I'm not sure what the point would have been.by dminik
7/24/2026 at 6:57:30 PM
Yes it was never attempted, the whole communication on social media about the AI policy was completely detached from the reality of the engineering work being done on either side.by kristoff_it
7/24/2026 at 8:06:29 PM
Yep, on rereading my comment I totally failed to make this clear. Cheers.by dtj1123
7/24/2026 at 1:55:14 PM
The port was line for line and full of unsafe code. It didn't prevent any bugs. They're not using Rust for its strengths.by Philip-J-Fry
7/24/2026 at 2:29:47 PM
You should give the article[0] a read."A large percentage of bugs from that list are use-after-free, double-free, and "forgot to free" in an error path. In safe Rust, these are compiler errors and RAII-like automatic cleanup with Drop. Compiler errors are a better feedback loop than a style guide."
"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 idiomatic Rust, but we are going to continue using C & C++ libraries like JavaScriptCore so it will always have more unsafe than pure Rust projects."
by skeledrew
7/24/2026 at 2:57:32 PM
That one’s interesting to me because it speaks to both sides of the debate. Yes, safe Rust is good for catching those kinds of errors at compile time. But also, it should theoretically be very easy for a compiler to avoid those problems in Zig, too, if you are using the language the way it wants to be used.Which, from what I’ve experienced so far, does seem to take a whole lot more effort if you’re using a coding agent. I spend an incredible amount of time making sure mine doesn’t bloat our codebase with Java-flavored Python, and all the noise and defects and performance problems that it brings.
by bunderbunder
7/24/2026 at 9:38:23 PM
> But also, it should theoretically be very easy for a compiler to avoid those problems in Zig, too, if you are using the language the way it wants to be used.agreed. in my side project im tinkering with a memory safety checker in zig that intercepts a compiler artifact, and it works better with idiomatic zig, problematic code is when you try to write c-isms in zig -- so i basicallt tell the checker to reject c-isms that create ambiguity for safety checking.
by dnautics
7/24/2026 at 3:26:47 PM
> using the language the way it wants to be used.This sounds like just the coding conventions dependency they're trying to avoid.
by skeledrew
7/25/2026 at 5:20:35 AM
IMO it's the same problem with Rust. LLMs are trained on vast quantities of code that violate Rust soundness in safe code.LLMs are prediction engines: you can move the needle (heavily) on the predictions from lazy to correct by construction, but the defaults even on high end models like Opus are always riddled with shortcuts.
LLMs can produce coherent & safe Rust 1.92, LLMs can produce coherent Zig 0.16, but that's dependent on in context learning & instruction following.
by TheGoddessInari
7/26/2026 at 12:17:03 AM
> that's dependent on in context learning & instruction followingNot just that. For Rust in particular, since unsafe code is uncompilable code (unless explicitly marked "unsafe"), the LLM is essentially forced to continue iterating even if the code already works but is unsafe, until it finds an implementation that's both correct (per the spec) and safe (per the compiler). That's the difference from Zig, where "make the code safe" is essentially part of the spec, and so may be missed by the LLM and not be discovered by a human until there's an observable runtime issue, or CVE.
by skeledrew
7/25/2026 at 11:28:38 AM
> LLMs are trained on vast quantities of code that violate Rust soundness in safe code.Why is your reasoning behind this? Most Rust code in the wild does not use unsafe. Most projects don't have a single line of unsafe.
by maleldil
7/24/2026 at 4:29:29 PM
Yup. But that also gets to the “they’re both right” angle. Zig’s convention may not be how the Bun developers wanted to work, but it’s a good choice for the kinds of projects Zig is designed for. Which overlaps a bit with, but isn't the same as, Rust’s intended use cases. For example, I might rather go with the Zig philosophy if I’ve got hard memory constraints and want to avoid dynamic memory allocation.Which, ironically, is something I’d love for my browser’s JavaScript runtime to do. But I can also respect others not wanting that.
by bunderbunder
7/25/2026 at 4:21:06 AM
I'm optimistic for that refactoring. But if one in 30 lines sprinkled all over everywhere is unsafe then you haven't actually done much to improve safety. When you have a large percent of fully safe functions and modules, that's when you're making a difference. Counting the lines is not a very helpful metric.by Dylan16807
7/26/2026 at 12:24:54 AM
> one in 30 lines> Counting the lines is not a very helpful metric.
Seems self-contradictory.
And they did say they're working to reduce the unsafe code over time. That huge percentage of memory bugs that they were able to better triage and fix due to the port was also them improving safety.
by skeledrew
7/26/2026 at 12:35:37 AM
The other part of that line is important. Measuring lines is better than nothing but the distribution is much more important. If they're scattered all over that's a bigger downside than the line reduction is an upside.If you want good metrics, measure functions and data structures without unsafe. Not lines.
by Dylan16807
7/26/2026 at 1:04:34 AM
> If you want good metrics, measure functions and data structures without unsafe.I doubt it, as it's possible a substantial amount of those unsafe areas can't even be removed, given the project's dependent on C/C++ libraries. Without proper calibration those metrics won't tell the full story, and with calibration the incentive for the story will decrease over time with the unsafe refactoring. I doubt the distribution of the unsafe code really matters that much; what matters is proper handling, wherever it is, so stability and security isn't compromised.
by skeledrew
7/25/2026 at 4:11:27 AM
The way I'm thinking of it is that they ported Bun from Zig to Unsafe Rust, and are still working on now porting it from Unsafe Rust to Rust (not 100% safe, but a reasonable amount).by sfink
7/24/2026 at 3:01:56 PM
The original Zig code is metaphorically one big unsafe block. Even if the Rust port is made up of 3% unsafe blocks, that still means 97% of the original Zig code has been made safe (in the Rust sense).by atombender
7/25/2026 at 1:58:04 AM
The safety of safe rust is created by extremely strong and subtle invariants that unsafe rust must maintain perfectly (or all bets are off). The idea that a program with tens of thousands of lines of vibe coded unsafe Rust is memory safe is mind boggling.by voidmain
7/25/2026 at 9:21:07 AM
IME agents are extremely happy to write more or less convincing // SAFETY: comments (most Rust code in the training set has these just before unsafe { - also it often works in unit tests). However, miri remains broadly unimpressed by comments.by formerly_proven
7/24/2026 at 5:34:20 PM
Of note, even that 97% of original code that is now "safe in the rust sense" could violate invariants through safe blocks that cause memory-safety issues. I can't say exactly how the LLM-ported Rust code made use of unsafe but see https://www.ralfj.de/blog/2016/01/09/the-scope-of-unsafe.htm...by ammar2
7/24/2026 at 7:59:33 PM
Not every line of zig is "unsafe".by jmull
7/26/2026 at 3:09:58 PM
No, but when the compiler isn't enforcing anything, how do you know which ones are safe and which ones are not? If we ignore declarations etc. and only consider statement lines that read or write memory, then any such line of Zig (or C, or C++, or any other unsafe language) can be classified as a potentially unsafe — not just today, but in the future, since safety bugs can be generated upstream by giving out pointers that aren't valid or concurrency-safe.by atombender
7/26/2026 at 4:40:53 PM
> If we ignore declarations etc. and only consider statement lines that read or write memory, then any such line of Zig (or C, or C++, or any other unsafe language)Surely it's obvious that's trivially untrue?
Also, literally no code is safe from potential future upstream changes.
Anyway, I'm not arguing zig has the same safety guarantees as rust. That would be silly. But the weird binary thinking around memory safety is equally silly. People want things to be simple, but you really can't come to good conclusions by trying to pretend things are simpler than they are and through a lack of analysis and thinking.
by jmull
7/24/2026 at 4:06:22 PM
Since they did a one-to-one translation to start with, hypothetically, if these were the true numbers, you could probably get a static analysis tool to guarantee you that 97% of the zig code was safe and tell you which of the 3% were unsafe. Zig has a lot more syntax and conventions to encourage safe code compare to C after all. It just doesn’t have way to mark which parts are safe or unsafe.An LLM could probably also trivially give you accurate reviews saying which parts were unsafe and in need of tests or reviews. I mean, considering their LLM budgets they could probably have had nightly reviews running every night for years before spending more than their Rust rewrite.
Not that I think Rust rewrite was a bad idea. Rust is a good fit for this kind of project. I say that as a Zig enthusiast. It’s just that their stated motivation and reported results are kinda BS. If they just wrote “we just like Rust and thought it’d be cool to see of LLM could do the whole rewrite”, and left it at that, I think it’d be a more honest description of the motivation. The rest is just rationalisation.
by audunw
7/24/2026 at 4:21:27 PM
No you cannot get a static analysis tool to guarantee 97% of zig code was safe. Well, you can - the tool is called the borrow checker.Do you know what's infinitely cheaper and faster than an LLM running nightly reviews of all of the code and infact mathematically provable that the code (and any new code) is memory safe? It's called the borrow checker.
by Zakis1
7/25/2026 at 5:46:33 AM
it seems like a reasonable enterprise to intercept the data dependency graph from the zig compiler and subject it to analysis to prove memory safety parameters:(my wip experiment: ) https://github.com/ityonemo/clr
by dnautics
7/24/2026 at 2:36:10 PM
They have made it very clear that the mechanical translation is the starting point, and are refactoring to remove as many unsafe declarations as possible.by samwillis
7/24/2026 at 2:53:53 PM
They turned every hidden memory safety bug into a grep'able memory safety bug. That's step 1 and a massive win.by insanitybit
7/24/2026 at 2:47:54 PM
That may have been the case for the initial iteration a few months ago, but is it still true?by neuronexmachina
7/25/2026 at 7:00:11 AM
This is an example of technical problems being easy but organization being hard imo. It is stupid if you think about it from a theoretical perspective but they didn’t want to use this feature for some reason.Probably because they did their fork of zig for fast compilation before and they didn’t want to just discard it and use this
by ozgrakkurt
7/25/2026 at 9:36:35 AM
Do the caveats mean that it could _not_ actually have had fast builds on all the platforms it supports? (Honestly asking if I connected the dots correctly here, this is not a snarky "actually" rethorical question...)by janpio