Live data from Hacker News

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

github.com

131–140 of 366 posts

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

#131

This Bun rewrite feels like a potential Mythos marketing stunt.

[flagged]

The HN guidelines specifically ask you not to do what you're doing, and say what to do if you have a genuine concern:

> Please don't post insinuations about astroturfing, shilling, brigading, foreign agents, and the like. It degrades discussion and is usually mistaken. If you're worried about abuse, email hn@ycombinator.com and we'll look at the data.

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

#132
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.

You have to do better than that if you're going to accuse the Zig team specifically of this.

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

#134
post #116
post #67

I was a little shocked that they could get it fully working in a week to be honest. My side project is a very similar ambition ( https://tsz.dev ) but I am in no way claiming success. i keep adding more and more tests to ensure things works. Even after all of TypeScript's own tests pass I am finding bugs which I was totally expecting. The bar for matching tsc's behavior is really _really_ high. see: https://github.co…

I'm stunned that it went from 'this is an experiment' to merging a ~million lines of (likely) unreviewed code in a week. I have nothing against using agents but to rush something like this and leave the community blindsided seems extremely ameteurish. Like something you'd expect a bright eyed graduate engineer to do.

tsz for me is an experiment to see how can this kind of work be done better. With a slight difference that tsz is not a direct port and it's a different architecture. I'm also not claiming to have answers but I've learned a ton. A few things that works

- Test before code, Bun had lots of test so that's good but maybe they could start by asking Mythos to write like 20k additional tests that pass on Zig Bun first.

- Deterministic anti-slop features. LLMs love to solve the problem in the wrong abstraction layer or place. There are many ways to catch this with deterministic tests. I do this in tsz a lot

- Roadmap that constantly evolving by humans.

- Taking a pause and looking how the progress is going and undoing slop

- Fuzztest(https://github.com/google/fuzztest) style "trying to break things" with the powers of LLM

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

#135

I'm curious, but unable to ascertain, does the same problem exist in the original Zig code? Is this an issue introduced by the translation to Rust? Because if it is a problem that can be replicated in both code bases, it seems a point in Rust's favor, that the issue is easily identifiable with tools that exist in its ecosystem.

I'm also curious about that. One thing to keep in mind: the invariants you have to uphold in unsafe blocks are quite stringent. I expect that in some instances the Rust code has new UB due to this.

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

#136
post #25

This doesn't seem surprising, given the straight translation that they prompted. Couldn't a case be made that it's better to get Bun to the to the language with the stronger type system first and, once there, use that stronger type system as leverage for these kinds of improvements as a follow-on effort? It seems preferable to requiring perfection on the very first step.

> Couldn't a case be made that it's better to get Bun to the to the language with the stronger type system first and, once there, use that stronger type system as leverage for these kinds of improvements as a follow-on effort? It seems preferable to requiring perfection on the very first step.

This is what they are doing.

They are working through the issues as they come in.

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

#137

Earlier quoted context omitted.

Indeed. My point is that just using the standard tools in the Rust ecosystem - like miri - would have trivially uncovered this error before it made it to the mainline.

This is an engineering choice: do you merge first and then fix the remaining issues or do you get everything perfectly clean first and then merge? I've seen large rewrites and migrations take both approaches -- in my experience, the former usually works out better.

In any practical application there'll be a known set of errors and I'm generally fine merging code that has known deficiencies. But personally, I'd not condone merging anything that causes UB. It undermines such a fundamental guarantee of the language that it should be detected and eliminated. And bun certainly rises to the level of software where I'd expect that the project runs all available tooling to detect such cases. Especially if you LLM - code it. "Do not cause UB" should be part of the test harness.

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

#138
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…

Sure, but the point remains. They could've used Claude to build a Zig to Rust converter, ended up with something that was both deterministic _and_ beneficial to the wider community.

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

#139

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…

That would have been the proper way to port a codebase to another language, by parsing the syntax tree and applying deterministic and verified transformations.
Post reply on HN