• tyler@programming.dev
    link
    fedilink
    arrow-up
    17
    ·
    8 days ago

    This Rust rewrite would’ve taken a team of engineers with full-context on the codebase a year of work

    Doubt.

    • SorteKanin@feddit.dkOP
      link
      fedilink
      arrow-up
      11
      ·
      8 days ago

      I mean it was 600,000 lines of Zig prior to the rewrite yea? If we say that a team is ~6 people, that’s 100,000 lines each to read through and translate. Assuming 250 working days in a year, that’s 400 lines of code you just need to read every day, let alone the Rust you need to be writing (approximately another 400 lines).

      Add to that overhead for planning and coordination… I actually think a year for a team might be an underestimate.

      • TehPers@beehaw.org
        link
        fedilink
        English
        arrow-up
        8
        ·
        8 days ago

        Zig’s features don’t map 1:1 to Rust’s features, so translating line-by-line (or file-by-file) doesn’t even make much sense. What are you supposed to do with a crazy comptime function full of reflection when translating that? What about custom pointer types (which Bun had to create for Rust), lifetimes, differences in ecosystem library APIs, etc?

        The author actually mentions the challenges they ran into due to breaking the code up across multiple crates. They needed to break cyclic dependencies for it all to compile.

        I agree. 1 year is an underestimate.

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    16
    ·
    8 days ago

    There are a lot of ways to do a terrible job of this. For example, prompting Claude “Rewrite Bun in Rust. Don’t make any mistakes.” and then praying it would work is not [sic] what I did.

    Adversarial workflows seems like an awesome strategy for burning tokens if your workplace uses a token leaderboard. I’m glad to see that someone discovered a way to game the system!

    I’m really hoping that Boa can compete soon. I’d love an embeddable, Rust-based JS engine that isn’t just AI generated unsafe everywhere. I don’t think they plan to really fit into the same space as node/deno/bun, but we already have node for that, and an easier to use JS runtime from within Rust would be awesome.

    • SorteKanin@feddit.dkOP
      link
      fedilink
      arrow-up
      8
      ·
      8 days ago

      Rust-based JS engine that isn’t just AI generated unsafe everywhere

      Tbf only 4% of the code was unsafe after the rewrite, which is much better than the 100% of the Zig code being unsafe. Honestly it’s not surprising you’d have such a large amount of unsafe when you translate Zig to Rust. But as I understand it, it’s since been refactored to much less than 4%.

    • trevor (any/all) @lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      8
      ·
      8 days ago

      This should definitely be required follow-up reading, as it puts many of the Bun article’s “too good to be true” claims into context.

      The fact that the Bun author didn’t know that Zig also has LTO really puts the rest of their claims into question.