News for hackers. Stuff that matters.
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by cyber_kinetist on Monday July 13, 2026 @07:32AM (#48891084)
> clear well-scoped unsafe boundaries

This is not done by blindly porting Zig code 1:1 and calling it a day. You do have to make conscious decisions about code architecture to manage Unsafe code, since you need choose the right invariants for your Safe Rust code to conform inside the module (Note that unsafe pollutes the whole module containing it, not just the code inside the unsafe block!)

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by baokaola on Monday July 13, 2026 @08:30AM (#48891700)
There's only one language that's more dangerous than C and that is unsafe Rust. I say that only half-jokingly.
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by hota_mazi on Monday July 13, 2026 @12:11PM (#48894822)
What do you mean?

C is unsafe 100% of the time. Rust is only unsafe in unsafe{} blocks.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by uecker on Monday July 13, 2026 @01:30PM (#48895985)
This is nonsense. There is quite a subset of C which is perfectly safe and an even larger one which can easily be safe with tooling. You could argue that unsafe keyword is easier to spot than the unsafe features of C, so that makes it somewhat easier to screen for issues. But if you screen for memory safety only, this is problematic anyhow.
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by selfmodruntime on Monday July 13, 2026 @10:02AM (#48892871)
It's true and I write Rust and love it dearly. There is an entire book about working with the unsafe keyword and its aliasing rules: https://doc.rust-lang.org/nomicon/working-with-unsafe.html
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by Ygg2 on Monday July 13, 2026 @08:38AM (#48891791)
Good job falling for the Zig propaganda. I say that half-jokingly.

EDIT: You can't be serious people. Rust unsafe is safer than C, if for nothing else, for knowing which pointers are aliasable.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by selfmodruntime on Monday July 13, 2026 @10:03AM (#48892878)
This isn't propaganda, the Rust compiler's rules when using the unsafe keyword are difficult to uphold, which is why the community wrote Miri.
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by Ygg2 on Monday July 13, 2026 @12:02PM (#48894706)
Ok, and how does, in your opinion, compiler rules enforcement work in an unsafe block?

And how does Miri help solve this issue?

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by selfmodruntime on Monday July 13, 2026 @05:08PM (#48898909)
> Ok, and how does, in your opinion, compiler rules enforcement work in an unsafe block?

By the engineer's wit of course!

> And how does Miri help solve this issue?

By detecting undefined behavior caused by violation these rules

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by dwattttt on Monday July 13, 2026 @06:02PM (#48899510)
Is there a "Rust compiler's rule" you can point to that's harder than avoiding UB in C or C++ in similar circumstances? They strike me as very similar beasts.
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by Ygg2 on Monday July 13, 2026 @10:22PM (#48901528)
> By the engineer's wit of course!

Seeing how the Rust compiler isn't an LLM, it can't really work on wit.

From the POV of a programmer, how would you implement an unsafe block? What is disabled vs what's enabled?

> By detecting undefined behavior

Say you are tasked with making Miri; how do you detect violations of these rules?

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by lolinder on Monday July 13, 2026 @09:15AM (#48892204)
No one involved in the port proposed "blindly porting Zig code 1:1 and calling it a day". From the first blog post the creator said:

> We can gradually refactor it to reduce unsafe usage and look more like idiomatic Rust after Bun v1.4 ships.

What the rewrite does is make the unsafe code greppable, which is a necessary first step to eliminating it and one that's actually achievable rather than going straight to idiomatic.

Every successful refractor takes this form of stepwise changes that leave the behavior intact. It just so happens that in this case the first stepwise change was the implementation language.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by cyber_kinetist on Monday July 13, 2026 @10:25AM (#48893246)
> We can gradually refactor it

Is quite a hell of a statement, when memory management issues are highly nonlocal and need some careful design upfront in order for you to nail it.

Unsafe isn't something that you can gradually clean up. Even one single flawed usage of unsafe (an ill-assumed invariant) can poison the whole program in scary ways, and might require a total refactor of your codebase to fix it.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by Tadpole9181 on Monday July 13, 2026 @10:39AM (#48893450)
You're not helping your case.

So if I use Zig, I need to do all of that perfectly from day one and I don't get any help from static analysis to do it. Or else I've poisoned my whole program in scary ways and will require a total refactor where I still won't have any help and once again can't make a single mistake.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by metoobruh on Monday July 13, 2026 @11:05AM (#48893842)
You're not helping your case.

> [what you just wrote]

So they gained nothing from a Rust rewrite, except introducing more bugs into their shit codebase.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by Tadpole9181 on Monday July 13, 2026 @12:09PM (#48894786)
Except the blog post shows that they fixed a hundred or so known issues, patching several memory leaks and making the project viable for Prisma Compute's adoption - which it wasn't before. It's now running in production in two places just fine.

Can you point to an equal number of issue tracker tickets showing novel bugs or regressions in the canary build?

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by endospore on Monday July 13, 2026 @08:40PM (#48900901)
Yes, they have introduced (at least) several times more memory safety issues by violating the rust specific rules. Check how most of their unsafe blocks are unsound and worse, how many are straight up incorrect with a total bs // SAFETY above it, leaving no sensible usage without invoking UB.

We often ensure a project holds water against miri. This one doesn't even pass for clippy.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by lolinder on Monday July 13, 2026 @10:50AM (#48893605)
You realize that what you're describing is inherent complexity in memory management? This is not something that you can dodge by using Zig, it's just part of the domain.

The difference is that in Rust you get strong guarantees for everything that is not inside of unsafe and clearly demarcated areas where things might go wrong. Even if you never eliminate a single unsafe block, the clear demarcation is valuable as an artifact in its own right.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by cyber_kinetist on Tuesday July 14, 2026 @05:47AM (#48904319)
The art of Unsafe Rust is marking the right demarcation with the right set of invariants that Safe code must adhere to inside the module that uses Unsafe. If you do this incorrectly, then even Safe code outside the unsafe block can cause undefined behavior.

Which is why having unsafe code without exactly specified invariants is practically useless: the Bun rewrite code has too many SAFETY comments that are incorrect and misleading, so most of the unsafe demarcations aren't helpful in achieving UB-free code.

Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by selfmodruntime on Monday July 13, 2026 @10:01AM (#48892846)
There is almost zero reason for a public facing, non-embedded project like Bun to use unsafe anywhere.
Re:Zig Creator Calls Spade a Spade, Anthropic Blows Smoke by cyber_kinetist on Monday July 13, 2026 @10:20AM (#48893175)
You do have to inevitably use unsafe because of FFI (Bun uses existing C++ modules like JavascriptCore for most functionality). Optionally also for performance (at least if you want to win Deno on that front)