Live data from Hacker News

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

github.com

81–90 of 366 posts

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

#81

This Bun rewrite feels like a potential Mythos marketing stunt.

[flagged]

> I've seen a lot of what seems to be inorganic defense of this, including one post from an account that hasn't posted in over a year.

It’s just a standard Pavlovian response of a bootlicker, it can also be triggered if you mention “tax the rich” and “regulate AI hyperscalers”.

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

#82

Dumbest point ever. There is no value for this issue. I don't agree with the way they did the rewrite, but they did the rewrite, and this post contributes nothing, beside making the author seem childish. If it had any real contribution I would have waved it off, but it really doesn't. This tribalism and "I'm better than you"-ism and the same reason everybody hated the stack overflow community, and the rust community…

The issue author is most likely quite literally a child.

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

#83

So many people are fundamentally misunderstanding everything about this rewrite. In fact using the word "rewrite" itself is pretty inaccurate. As has been mentioned the goal was a port so they "could" eventually rewrite most of it to be idiomatic rust. The main benefit of this now is the compiler and being able to use these tools to fix issues that were already being hidden when it was in zig. If you go into this cod…

[deleted]

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

#84

Earlier quoted context omitted.

[flagged]

I'm not sure that HN is that influential that buying up a few accounts would matter. To what end?

If you can increase your reach, why not do it? Also, HN has better reputation among tech circles than Reddit and is less niche than other resources. Modern marketing hits everything.

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

#85

What I don't understand is if they were going to translate Zig to unsafe Rust, why not just build a translation tool for it? You could do a one-to-one mapping of language constructs, hardcoding patterns in your codebase, and as one friend put it "Tbh they could've just hooked up zig translate-c to c2rust". They would get deterministic translation, would probably have not been a heavy investment to build, and the outp…

“Tbh they could've just hooked up zig translate-c to c2rust”

This doesn’t work like you think it does. These things are full of errors and make the code very verbose and hard to reason about. It works with small apps, not entire rewrites.

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

#86
post #70

What I don't understand is if they were going to translate Zig to unsafe Rust, why not just build a translation tool for it? You could do a one-to-one mapping of language constructs, hardcoding patterns in your codebase, and as one friend put it "Tbh they could've just hooked up zig translate-c to c2rust". They would get deterministic translation, would probably have not been a heavy investment to build, and the outp…

> "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…

What they’ve done here isn’t safe either, and doesn’t have the consistent translation of rust2c.

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

#87
post #62

Earlier quoted context omitted.

No, and there's been a lot of confusion about that on this website. They did cite Rust's safety as a motivating factor for the port. That doesn't imply trying to achieve that simultaneously with the language change — which is good, because that would be insane. (Or, if you prefer, even more insane.) You cannot faithfully port a codebase to a new language while also radically re-architecting it. You have to choose. Th…

Yeah, exactly. The typical approach is to do a mechanical translation such as with rust2c, that is full of unsafe, and then gradually refactor safety in.

But nobody makes announcements and blog posts about running that.

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

#88

This Bun rewrite feels like a potential Mythos marketing stunt.

Not a single person on the Bun team nor Anthropic has yet done anything egregious to market this as anything but a swap to a more memory-safe language with better compiler guarantees.

Thus far most of the buzz and marketing has been entirely negative from people who are against AI.

My take is that most of the buzz is also tied to recent negative opinions of Anthropic themselves due to some of their recent decisions.

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

#89
post #65

Earlier quoted context omitted.

Philosophically motivated, sure. In what way is the Zig foundation's AI stance political?

I think that we only see these bans because AI has become such a massive political issue in the last year.

Define “political” when it comes to Zig and AI.

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

#90
post #38
post #28

Earlier quoted context omitted.

Safe Rust does. Unsafe Rust allows you to tell the compiler “hold my beer”. It’s a concession to the reality that the normal restrictions of Rust disallow some semantically valid programs that you might otherwise want to write. The safeguards work great in most cases, but in some they’re overly restrictive. In practice, the overwhelming majority of code is able to be written in safe Rust and the compiler can have you…

OK but the title says "in safe Rust". Am I misunderstanding something? All the replies here are saying how it's allowed in unsafe Rust, which is not what the title says.

Unsafe blocks are you saying to the compiler 'trust me bro, I know this is safe'. But often that relies on some property of the code being true in order for it to actually be safe. Generally speaking, the expectation in rust is that you either encapsulate the code that enforces whatever property you are relying on behind a safe interface, so that it's not possible for other code to use it unsafely, or that you mark the interface itself unsafe so that it's obvious that the code using that interface needs to maintain that property itself. Rust code that doesn't do this will generally be considered buggy by most rust programmers (e.g. if you find a use of safe interfaces in the stdlib that causes a memory safety violation, then you should file a ticket with the rust team), but this is essentially only a social convention of where the blame lies for a bug, not something that compiler itself can enforce (and, for example, you can violate memory safety in rust with only safe std interface by abusing OS interfaces like /proc/self/mem but this is something that most people don't think can be reasonably fixed). The main reason that rust as a language is better in this regard is that it gives much better tools for being able to express that safe interface without giving up performance and that it has the means to mark and encapsulate this safe/unsafe distinction.

Here's some links on this topic which have some examples:

https://doc.rust-lang.org/nomicon/working-with-unsafe.html https://www.ralfj.de/blog/2016/01/09/the-scope-of-unsafe.htm...

Post reply on HN