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

Context of the Bun Rust Port

  • Bun’s core was mechanically ported from Zig to Rust, heavily using LLMs and unsafe Rust, with a ~1M‑line commit merged to main.
  • The Zig implementation remains for now as the stable path; the Rust port is described as a starting point, not a finished product.
  • Some see the move as primarily about getting onto a language with stronger safety tools, then iterating; others see it as an AI marketing play tied to Bun’s acquisition.

Rust, Unsafe, and Undefined Behavior

  • Multiple commenters explain that Rust only guarantees memory safety for purely safe code; unsafe blocks are “you promised the compiler this is OK.”
  • UB can be triggered later from safe code if an unsafe abstraction is incorrectly wrapped and exposed as safe.
  • The controversial issue is not “UB exists” but that a supposedly safe API permits UB, meaning the abstraction is unsound.

Quality of the Port and Miri Findings

  • Miri, a Rust interpreter for catching UB, quickly found issues (e.g., around a custom PathString type using packed pointer/length tricks and violating pointer provenance rules).
  • Some argue such tools should have been run before merging to main; others see “merge then clean up with tools” as a legitimate migration strategy.
  • Debate over whether certain UB existed in Zig: some say yes (same logic), others say Rust’s stricter invariants created new UB that didn’t exist before.

AI-Driven Rewrite: Promise vs “Slop”

  • Supporters: LLMs are now good at large translations; port first, then use Rust’s type system, Miri, fuzzing, and agents to iteratively harden the code.
  • Critics: the result is “slop” — thousands of unsafe lines, invented abstractions that erase lifetimes, and no human-reviewed understanding of the new codebase.
  • Concern that future work will be forced through AI because no one fully understands the rewritten core.

Project Management and Community Trust

  • Many object to merging a massive LLM port straight into main (and auto‑releasing canaries) instead of keeping it on a long‑lived branch.
  • Some users report already migrating away from Bun, viewing this as a “rug pull” or betrayal of earlier engineering discipline.
  • Others say judging intermediate states is unfair; open development plus public dogpiling is pushing maintainers to lock issues and be more closed.

Zig, AI Policies, and Language Choice

  • Part of the backdrop is Zig’s explicit “no AI contributions” policy for its compiler and earlier rejection of Bun’s Zig fork changes.
  • Some say this justifies moving off Zig; others emphasize Zig’s stance as pragmatic protection against low‑quality AI PRs.

Meta-discussion and Tone

  • Thread highlights polarized attitudes toward AI (from “case-closed proof AI can replace many engineers” to “anti‑intellectual move-fast slop”).
  • Several worry about low‑quality, tribal discourse and the difficulty of doing nuanced technical work under public pile‑ons.