Bun’s founder experimented with a massive agentic rewrite from Zig to unsafe Rust.
That experiment was merged days later and is now the official version.
Wait, they ai yolo from a memory safe language to an unsafe version of a different memory save language?
yes, but when you make a port from one language to another, usually you want to rewrite it as a translation first, then refactor later with the features that language provides. A port that refactors everything in the first release is too risky.
The fact the translation has unsafe blocks only demonstrates the Zig version is not really safe as per Rust standards.
It depends on where exactly that 5% lies. If it’s in the core API that’s used by the rest of the architecture, it essentially makes the whole codebase unsafe when used irresponsibly.
I don’t know if that’s the case here, just pointing out that the 5% doesn’t mean much.
Not exactly. It means that any of the code could lead to memory unsafety, but it’s still better than Zig or C because you still only have to read 5% of the code to debug/fix those issues, instead of 100%.
5% is clearly better than 100%. Whatever else you think about this port you can’t argue against that. In fact I can prove that it’s better.
Does Rust’s memory safety design improve memory safety? Yes, this is proven by experience (e.g. see Google’s blog posts).
Does “normal” (not slop) Rust code rely on someunsafe? Yes. All Rust code must use some unsafe because it’s used in the standard library, and even if you ignore that (there is an effort led by Amazon to formally verify it), it’s usual for Rust projects to use at least some unsafe. Let’s say 0.1% of lines.
So 0.1% unsafe is clearly better than 100%. Is it possible for 0.1% unsafe to be better than 100%, but somehow 5% isn’t? That would require things to be non-monotonic which is completely implausible.
I’m sorry, but since we’re being pedantic, this is not a proof. It’s full of assumptions, some of which are wrong.
5% is clearly better than 100%
Never denied it. 0% is even better. What matters is where it’s used. If it’s used for FFI, that’s understandable. Any other use should be scrutinized more. And that’s the issue. The claim of Zig’s creator is that the devs of Bun are not reliable. And to me at least, his arguments make sense.
it’s usual for Rust projects to use at least some unsafe
Doesn’t seem like it. This article claims that only about 20% of Rust code uses unsafe at all. Even among those, the vast majority uses it for FFI, which is unavoidable.
but somehow 5% isn’t
Again, no one claimed that. But we need more than “better than 100%” when it’s a JS runtime. And the "better"ness isn’t necessarily linear. So, even though it might be technically “better”, it might not be by much. At that point, what even is the point of the rewrite?
Again, I’m not claiming that it’s actually badly written. I’m only claiming that your arguments are not adequate, and that Bun is not a reliable company, so take whatever they claim with a grain of salt.
Wait, they ai yolo from a memory safe language to an unsafe version of a different memory save language?
Zig is not as strict as Rust for memory management
Unsafe rust too
yes, but when you make a port from one language to another, usually you want to rewrite it as a translation first, then refactor later with the features that language provides. A port that refactors everything in the first release is too risky.
The fact the translation has unsafe blocks only demonstrates the Zig version is not really safe as per Rust standards.
my comment was just pointing out to unsafe rust blocks used in sloppy rewrite.
You clearly don’t even know what
unsafein rust means. And it’s not something you can avoid when FFI is involved, slopping involved or otherwise.Claude is it you?
😇
I do love me some internet gantry commentary. Especially when it’s super confident and acting knowledgable, with multiple layers of genius on display.
where is quote from? You pretend this is a quote of something I wrote?
I see what you’re saying, but there’s no need to be rude.
Sure, but only 5% of the Rust code is unsafe, which is clearly an improvement. And their plan is to reduce that amount over time.
I’m no fan of AI slop but that point isn’t an issue.
It depends on where exactly that 5% lies. If it’s in the core API that’s used by the rest of the architecture, it essentially makes the whole codebase unsafe when used irresponsibly.
I don’t know if that’s the case here, just pointing out that the 5% doesn’t mean much.
Not exactly. It means that any of the code could lead to memory unsafety, but it’s still better than Zig or C because you still only have to read 5% of the code to debug/fix those issues, instead of 100%.
5% is clearly better than 100%. Whatever else you think about this port you can’t argue against that. In fact I can prove that it’s better.
Does Rust’s memory safety design improve memory safety? Yes, this is proven by experience (e.g. see Google’s blog posts).
Does “normal” (not slop) Rust code rely on some
unsafe? Yes. All Rust code must use someunsafebecause it’s used in the standard library, and even if you ignore that (there is an effort led by Amazon to formally verify it), it’s usual for Rust projects to use at least someunsafe. Let’s say 0.1% of lines.So 0.1% unsafe is clearly better than 100%. Is it possible for 0.1% unsafe to be better than 100%, but somehow 5% isn’t? That would require things to be non-monotonic which is completely implausible.
I’m sorry, but since we’re being pedantic, this is not a proof. It’s full of assumptions, some of which are wrong.
Never denied it. 0% is even better. What matters is where it’s used. If it’s used for FFI, that’s understandable. Any other use should be scrutinized more. And that’s the issue. The claim of Zig’s creator is that the devs of Bun are not reliable. And to me at least, his arguments make sense.
Doesn’t seem like it. This article claims that only about 20% of Rust code uses
unsafeat all. Even among those, the vast majority uses it for FFI, which is unavoidable.Again, no one claimed that. But we need more than “better than 100%” when it’s a JS runtime. And the "better"ness isn’t necessarily linear. So, even though it might be technically “better”, it might not be by much. At that point, what even is the point of the rewrite?
Again, I’m not claiming that it’s actually badly written. I’m only claiming that your arguments are not adequate, and that Bun is not a reliable company, so take whatever they claim with a grain of salt.