Live data from Hacker News

Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

github.com

361–366 of 366 posts

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#361
post #70

Earlier quoted context omitted.

> "Tbh they could've just hooked up zig translate-c to c2rust". Have you ever seen what comes out of c2rust? It's awful. It relies on a library of functions which emulate unsafe C pointer semantics with unsafe Rust. A few years ago, when I was struggling with bugs in OpenJPEG (a JPEG 2000 decoder), someone tried running it through c2rust. The converted unsafe rust segfaulted at the same place the C code did. It's com…

> The converted unsafe rust segfaulted at the same place the C code did. It's compatible, but not safe That is indeed the point of c2rust. It gives you a baseline that is semantically identical to the original codebase, and with that passing the full test suite, bug-for-bug, you can then start gradually adopting rusty idioms to improve the memory safety of the codebase.

c2rust can generate UB in Rust even when there is no UB in the original C. It isn't bug-free, and C and Rust's undefined behavior semantics overlap but aren't identical.

One example: https://github.com/immunant/c2rust/issues/1678

I firmly believe the right way to port C and C++ (and Zig) programs to Rust is to do it module by module ("Ship of Theseus"). It needs scrutiny by folks who know both languages deeply, and you can port test cases too so you can detect UB at runtime (using tools like Miri). That's what fish did, and their port has been quite successful.

Blindly trusting the results of a machine translation is never a good idea. Especially when the translator has a temperature parameter.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#362
post #360
post #359

Earlier quoted context omitted.

I also meant Deno as well.

Oh. Well, then, yes I agree. It certainly does remain to be proven if anybody can make "Node, but better" a business. Certainly the recent layoffs¹ of ~half-or-so of the Deno team doesn't bode well for it, as AFAIK Bun was the only other significant player trying (to make it a business). ¹: https://www.reddit.com/r/Deno/comments/1rwjaeb/whats_going_o...

[deleted]

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#363
post #168

Earlier quoted context omitted.

A bug-for-bug port to Rust is the first step to fixing that. Assuming the port is actually 1:1 without any behavioral changes, these bugs already exist in the Zig code. The difference is now it's known where effort can be dedicated in order to one day have a memory-safe release of Bun. People have absolutely lost their mind over this and completely forgotten the benefits Rust gives you. I feel like I've gone back 10…

> Assuming the port is actually 1:1 without any behavioral changes, these bugs already exist in the Zig code The "1:1" assumption is a massive unjustified assumption. Rust and Zig have different memory models, so it's possible to do a "1:1" translation of Zig code to Rust and end up with undefined behavior in Rust. For example, Zig code might make assumptions about lifetimes based on implicit knowledge of which alloc…

can't help myself: how common to see code like https://github.com/oven-sh/bun/blob/main/src/bun_core/string... instead of simple ilog2()? I guess, ut somewhat explains how they got 700k+ lines of code

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#364
post #322

Earlier quoted context omitted.

I was thinking of https://news.ycombinator.com/item?id=48152395 . If I hadn't seen that one, I probably wouldn't have interpreted the GP this way.

that's a pretty substantive comment imo. it pretty succinctly explains an issue we are having in 2026.

It did nothing but deliver pejoratives.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#365

Earlier quoted context omitted.

They don't have to do that at all. They could've used mainline Zig, without their vibe coded changes to it.

They changed Zig because it was inadequate for their efforts, why would I keep using a tool that is inadequate if there's a better tool?

They claim to have made the Zig compiler faster, which is disputed. Even if true that wouldn't make it inadequate without their changes.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#366

Earlier quoted context omitted.

rooted in a long 30+ year reality. you can engineer the greatest, most secure, most accessible, most ____ thing but if it doesn’t sell those amazeballs engineers will be talking to their recruiters…

That's fine but I'll say as a human, that makes you a pretty crappy one. Only caring about monetary rewards is pathetic frankly, luckily the vast majority of humans don't agree with this sentiment and continue pushing the boundaries and our imaginations onward.

I have some programming work for you to do unpaid of course since only caring about monetary rewards is pathetic. But I'm sure you'll be able to feed yourself on exposure right?

Grow up.

Post reply on HN