Rewriting Bun in Rust

(bun.com)

217 points | by afturner 2 hours ago

28 comments

  • YuechenLi 1 hour ago
    >Combined with the Rust rewrite, ICU changes, and identical code folding, Bun's binary size shrinks by ~20% on Linux & Windows.

    People who are surprised by this probably has not seen what Zig code actually looks like. Zig's explicitness and lack of abstraction have a real cost that it is basically one of the most verbose programming languages I've ever seen, it's somehow even more verbose than Go. Basic features of modern languages like pattern matching and generics, and as you can see, having to manually clean up everything means that if you forget once, it's a memory leak. Having SOME abstraction is actually good if it prevents you from making mistakes.

    Ironically, Zig is a programming language that's probably best written by LLMs, since they can actually tolerate the verbosity.

    • benced 59 minutes ago
      Not a compiler expert - shouldn't language verbosity and binary size be, at best, very loosely related?
      • YuechenLi 20 minutes ago
        Fair point, I phrased that too broadly, and you are right about the loose correlation.

        What I was gesturing at, badly, was more that Zig’s low-abstraction / explicit-by-default syntax tends to have you write more boilerplate-y code in general that are more annoying to write and maintain, while not buying you enough over a language with better tooling and ecosystem and compiler optimization like Rust.

      • surajrmal 5 minutes ago
        Why? Python is terse but has large binaries because of the runtime overhead. C++ is fairly verbose but can make useful binaries in double digit kib.
      • steveklabnik 51 minutes ago
        I don't think you can draw the conclusion that source length and binary size are correlated. For example, in Rust:

            #[derive(Copy, Clone)]
            enum Expr {
                Int(i32),
                Add(i32, i32),
                Neg(i32),
            }
            
            fn eval(expr: Expr) -> i32 {
                match expr {
                    Expr::Int(x) => x,
                    Expr::Add(a, b) => a + b,
                    Expr::Neg(x) => -x,
                }
            }
        
        Rust's enums can carry data. You can write the same thing in C, but because it does not have the enum feature, you have to do it yourself. They're sometimes called "tagged unions" for a reason, you use a union + a tag when doing it by hand:

            #include <stdint.h>
            
            typedef enum {
                EXPR_INT,
                EXPR_ADD,
                EXPR_NEG,
            } ExprTag;
            
            typedef struct {
                ExprTag tag;
                union {
                    struct {
                        int32_t value;
                    } Int;
            
                    struct {
                        int32_t left;
                        int32_t right;
                    } Add;
            
                    struct {
                        int32_t value;
                    } Neg;
                };
            } Expr;
            
            int32_t eval(Expr expr) {
                switch (expr.tag) {
                    case EXPR_INT:
                        return expr.Int.value;
            
                    case EXPR_ADD:
                        return expr.Add.left + expr.Add.right;
            
                    case EXPR_NEG:
                        return -expr.Neg.value;
                }
            
                __builtin_unreachable();
            }
        
        I haven't actually compiled this, but it should compile to almost the exact same, if not literally the exact same, machine code. Yet one is way more verbose than the other.
        • pavon 48 minutes ago
          I think you are saying the same thing as benced - just because Zig source code is verbose is no reason to assume the binary should be larger.
          • steveklabnik 44 minutes ago
            I read my parent ask asking a question: is there a correlation, or not?

            I am saying that I do not believe there is a correlation between source code length and binary length. If that's what benced meant by their question, then yes, I agree :)

            • esjeon 23 minutes ago
              I’m quite sure there is a certain amount of correlation unfortunately, mainly because there are micro patterns (e.g. IO, allocator) that can’t be modularized into functions. Lots of manual copy-pasta.
        • 14113 27 minutes ago
          It required a little bit of messing with optimisation settings and library generation in Rust, but they emit very very similar x86-64 assembly:

          https://godbolt.org/z/89W4srz4d

          • steveklabnik 22 minutes ago
            Nice, thank you for picking up after my laziness. Surely only a few bytes different in the binary, and much, much smaller of a delta than the source.
    • typ 11 minutes ago
      Abstraction doesn't necessarily lead to a smaller binary. Much of the bloat in modern software is indeed due to (bad) abstractions.
    • giancarlostoro 1 hour ago
      > Ironically, Zig is a programming language that's probably best written by LLMs, since they can tolerate actually tolerate the verbosity.

      Rust in my opinion feels the same.

      • pjjpo 13 minutes ago
        I have found LLMs struggle with Rust's constraints - they are optimized to produce code that passes the tests, not necessarily good code. So instead of working out lifetimes and borrowing, it will be happy to copy a buffer many times without thought. This means I have to still go through line by line to review and often rewrite either by hand or with another LLM iteration.

        There may be some prompting that can help with this but I suspect there is a fundamental tension between writing working code vs good code in LLMs. Go is popular for being simple, making it easy to jump in and write something fast and stable - minimizing the gap between working and good code probably helps out the LLMs a lot.

      • afavour 44 minutes ago
        I don’t feel the verbosity with Rust. Haven’t written it in a while but now in the LLM era I’m looking forward to saying “sort out the lifetime errors for me”.
        • i_am_a_peasant 42 minutes ago
          I trust a lot more Rust code generated by an LLM than anything else ngl.
      • sroussey 1 hour ago
        Agree. But just because it feels the same doesn’t mean it compiles the same.
      • honeycrispy 53 minutes ago
        That can often depend on how you write it.
    • bsder 24 minutes ago
      Naive was 4-9% on the initial pass.

      Also note that the larger percentages were against already smaller binaries. That smells like there was a single large constant number that got saved somewhere rather than general improvements.

      > After that initial shrinkage, the team explored more opportunities for binary size reduction using linker optimizations like Identical Code Folding, removing unused data from ICU, and lazily decompressing small parts of libicu with a zstd dictionary on-demand.

      I'd be VERY interested in seeing what the individual effects of those parts were.

  • dabinat 14 minutes ago
    > This Rust rewrite would've taken a team of engineers with full-context on the codebase a year of work. With 1 engineer using Fable & closely monitoring Claude Code, we went from start to 100% of the test suite passing on all platforms in 11 days.

    This is impressive from a technological standpoint, but it does gloss over the fact that it would have cost $165k in tokens were Bun not part of Anthropic.

    The comparison here isn’t completely fair - it would take a small team a year to port it if they spent $0 extra on it.

    I’d be interested to see a comparison between spending $165k in 11 days on Claude vs splitting that between 50 people over 11 days for a line-by-line rewrite of the Zig code. I suspect Claude might be faster and therefore cheaper, but maybe not by a lot.

    • Philpax 12 minutes ago
      I think it'd take you at least eleven days to meaningfully coordinate 50 people!
    • tekacs 13 minutes ago
      I feel like a core difference is that the AI implementor can get cheaper/faster (and indeed _uniformly_ better), whereas it would be very difficult for the same humans to do so.

      Even if this is not the right answer today, it can at the very least serve as a herald of a possible future, no?

    • Jenk 10 minutes ago
      $165k won't get you far on salaried engineers. There's every chance that 1 engineer, assuming Anthropic employs them, is on $500k or more. Assuming average of $336k in that pool of 50 engineers, then for 11 days for 50 engineers you've spent $710k[0].

      Salary info: https://www.levels.fyi/companies/anthropic/salaries/software...

      [0]The maths I used (posting because I'm tired and prone to mistakes):

          $336,000 / 260 (working days of the year) = ~$1,292.
          $1,292 * 11 * 50 = ~$710,769
  • didibus 27 minutes ago
    Article did a decent job of showing discipline and care and human involvement to assert the automated rewrite was done diligently, as best as it can be when using AI for it. I does make me feel a bit more comfortable about it.

    As an aside, I don't know why anyone would not want to use a memory-safe (and possibly race-safe) language in 2026. Rust gives you that in a performant package, so if you are turned off by GCs and immutability for performance reasons, you still have the option to use Rust.

    I can understand when you need the absolute best performance and you decide to drop to down to C++, and I also relate with just personal preference, but beyond those it seems a no brainer to me.

    • leecommamichael 6 minutes ago
      > As an aside, I don't know why anyone would not want to use a memory-safe (and possibly race-safe) language in 2026.

      The rust compiler is very slow. The best way to speed it up appears to be organizing a codebase in many crates. This is not preferable ergonomics to many. Beside that, for many problems, a garbage collector eliminates a large amount of defects (including the ones stated in the article) without any added friction, whereas Rust asks that you think in terms of ownership. This is not preferable ergonomics to many.

      I realize what I'm saying above, while true, doesn't give a clear example. Many gamedevs would rather iterate with a language that is lower friction, not only because game code is finnicky (like frontend UI code) but because the build process can be unique. Many gamedevs prefer to iterate with hot-reloading, and asking them to use a slower compiler is asking them to accept greater latency in that cycle.

      I do not claim that these reasons apply to everyone.

      • gpm 0 minutes ago
        [delayed]
  • Philpax 1 hour ago
    Without commenting on Bun itself as a project, or the nature of the rewrite, it can't be good for Zig that a naive rewrite away from it fixed memory leaks, improved stability, shrunk binary size by 20%, and improved performance by 5%.
    • simonw 19 minutes ago
      I don't think it's care to categorize this as "a naive rewrite away from [Zig]" - Jarred has been immersed in this project for five years, got to benefit from everything he learned along the way and spent $165,000 of tokens on the most advanced coding LLM anyone has access to.

      I expect if he'd spent $165,000 running Fable against the Zig version he could have got a 5% performance improvement, too.

      • Philpax 9 minutes ago
        Oh, I have no doubt that they could have extracted those gains from Zig! My point is more that, from a relatively naive line-to-line port, they were able to claim these benefits without much effort.

        It's not great for Zig if you have to put in more work to end up at the same place, efficiency-wise, especially for a language marketed at people who like to get the most out of their metal.

    • frollogaston 24 minutes ago
      I pay attention when someone makes a hard decision based on a hard-learned lesson. It's like, most who choose to use an ORM just heard of it or want to avoid learning SQL, everyone who removes an ORM learned firsthand horrors.
    • bielok 1 hour ago
      I would guess that people looking to use Zig understand that those are project concerns and not language concerns.
      • Zakis1 1 hour ago
        The stability gains are a direct language concern as mentioned throughout the article.
    • pyrolistical 1 hour ago
      Yeah but they turned it into something unreadable. Call it a skill issue if you wish.

      I just haven’t found another language that just makes sense. Zig doesn’t hide anything from you

      • kgeist 53 minutes ago
        >they turned it into something unreadable

        Did you compare the code before/after? It's a mechanical line-by-line port, and most of the code is identical to the old version, just with Rust syntax. They have an example in the blog post.

      • lifthrasiir 1 hour ago
        The article explicitly mentions the maintainability as a foremost concern.
        • silver_silver 46 minutes ago
          People say a lot of things, especially when they have a vested interest in a positive outcome. Bun has been fully vibe coded into another language. There’s no way in hell it’s maintainable. Go read any analysis of the Claude Code leak for proof.
          • lifthrasiir 41 minutes ago
            Claude Code is entirely vibe-coded for a long time. Bun isn't. You go read and compare the actual Bun code; it reads reasonably well [1].

            [1] For example, as a random sample, https://github.com/oven-sh/bun/blob/bun-v1.3.14/src/css/medi... -> https://github.com/oven-sh/bun/blob/4924862cffbf671792d47c92...

            • silver_silver 26 minutes ago
              Sure, reasonably well at first glance, but to quote the article:

              > I rewrote Bun in Rust using about 50 dynamic workflows in Claude Code run continuously over the course of 11 days.

              > Excluding comments, Bun is 535,496 lines of Zig.

              > How do you review a PR with +1 million lines added? How do you start to build the confidence needed to responsibly merge large quantities of LLM-authored code? A language-independent test suite with a million assertions, adversarial code review and when something does go wrong, fixing the process that generates the code instead of hand-fixing the code.

              That’s vibe coding. This blog post is an ad for Claude, nothing more.

              • teach 21 minutes ago
                You're entitled to call things as you wish, of course, but your definition of "vibe-coding" differs quite a bit from mine.
              • frollogaston 17 minutes ago
                Doesn't look like vibecoding to me. It does look like a Claude ad, but they do have a vested interest in not screwing up Bun now that they own it.
          • daishi55 18 minutes ago
            > There’s no way in hell it’s maintainable

            This is not an assertion you are qualified to make

            > Go read any analysis of the Claude Code leak for proof

            You seem to be implying that Claude code is unmaintainable. Yet they appear to be maintaining it just fine. Did I misunderstand your implication?

            • fragmede 7 minutes ago
              Claude code is buggy and they don't appear to be maintaining it just fine.
              • daishi55 0 minutes ago
                I use it all day every day and haven’t noticed any bugs.

                And the fact is that they are maintaining it and it is one of the most successful software products of all time and is earning them mountains of cash. By any metric it is a successful product. So obviously whatever they are doing is working.

    • lifthrasiir 1 hour ago
      The same concern applies to every GC language, so it's not necessarily bad for Zig. Bun can have been grown too large for Zig to be effective, while moderately sized projects may still greatly benefit from Zig.
      • saghm 38 minutes ago
        I thought Zig was supposed to be a C replacement (as in, it doesn't actually provide full safety in the way that Rust or a GC language would)?
        • lifthrasiir 36 minutes ago
          Oh, yeah that might be confusing. I meant "you can say the same thing for GC language if that's true, which isn't necessarily true, so that must be false".

          More precisely speaking: GC languages are said to delay memory problems far beyond the horizon, which is often unreachable throughout the project's history. Zig can be a similar case.

    • throwaway27448 1 hour ago
      True, but rewrites often allow for this sort of benefit in themselves. It's possible rewriting it in zig would have yielded some of the same improvements.
      • pdpi 1 hour ago
        A sophisticated rewrite? Sure. This was a naive like-for-like rewrite, though.
    • geon 1 hour ago
      Wouldn't the same improvements have been made in zig if they instructed the agents to improve instead of rewrite?
      • gpm 20 minutes ago
        Maybe they'd get the same numeric improvements and bug fixes today (or maybe not, or maybe they'd get even more since the LLM isn't spending time rewriting correct code).

        But they wouldn't get a change to the structural issues that created the issues in the first place. They'd end up "ke[eping] fixing these kinds of bugs one-off in perpetuity".

      • Zakis1 54 minutes ago
        But how would you verify that the agents have written memory safe code? Rust's borrowchecker is a lot faster and actually verifiably safe compared to asking an LLM to fix the safety issues that the Zig version had.
    • rq1 1 hour ago
      From a PL Theory perspective, Zig is vibe-coded.

      Not sure why people use it.

  • theLiminator 1 hour ago
    That's the power of a strong test suite. LLMs excel when you have verifiable rewards. I imagine we'll get a lot more rewritten in rust projects in the future. Rust is also an ideal target for such rewrites as it offers a lot of verification (via its type system) and is low overhead with zero-gc. There's less and less reason to use GC'd languages in the agentic coding era.

    I think Rust is a locally optimal target for LLM coding, we might see a better language in the future, but I think Rust will dominate for quite some time.

    • lifthrasiir 1 hour ago
      > There's less and less reason to use GC'd languages in the agentic coding era.

      Faster iteration, maybe? Rust's safety guarantee isn't exactly free (while still being very excellent) and does affect iteration time. I have a private project (>300K LoC) that has been translated from Python to TypeScript and the reason we couldn't use Rust was definitely the iteration time.

      • talloaktrees 26 minutes ago
        I like using Odin with LLMs for this. it's a simple statically typed language with no GC and very fast compile
      • gpm 58 minutes ago
        Eh... rust's safety isn't free, but not having it and wasting time on "oh I forgot to change this call site" also isn't free. On the whole I'd say the safety assists in iteration time.

        What costs rust in iteration time in my opinion is the low level (by default) nature of it. There's a faster-to-iterate language that has yet to be created which is rust but we sacrifice performance (and memory fiddling ergonomics for the odd person who does that) so we don't have to worry about things like whether a variable is stack or heap allocated. Which is in the direction of a GCed language but retains the mutable-xor-aliasable semantics.

        Between rust and current GCed languages though... I guess I agree with "maybe" in both directions.

        • lifthrasiir 34 minutes ago
          The project in question needed lots of near-instant human judgements and the iteration loop had to be extremely tight. Maybe Rust should be reconsidered once it gets stabilized enough, but not right now.
        • theLiminator 53 minutes ago
          Maybe something like Hylo? But personally I don't see anything displacing rust for the next few years, as I think there's enough rust in the training data for it to be the best "serious" language for agentic systems-level development.

          It's really the only systems language in its exact niche.

          • gpm 32 minutes ago
            I'm not very familiar with Hylo, but I think it's in the opposite direction from rust than what I'm suggesting.

            I'm suggesting a language where there's no difference between Box<u32> and u32. &Vec<u8> and &[u8] are the same thing. I don't need to write Box::new(...) around my closures to pass them to functions that take a function pointer. This comes with overhead, but in exchange we get simpler less verbose code. I.e. a language that isn't systems level, and isn't particularly machine-empathetic. But still has all the lightweight-formal-methods power of rust with lifetimes and mutable vs shared borrows (and thus references to references) and so on.

            My impression of Hylo is that it's purpose is to be a similarly low level systems language to rust, just with a less complicated, and as a consequence less expressive, lightweight formal methods system for proving correctness.

            I agree I don't expect rust to be displaced anytime soon. It creates a lot of time to create a good compiler, and a lot more to create the ecosystem of code, tools, and community around it.

  • thevinter 2 hours ago
    One thing that I found interesting is that most of the discourse surrounding the topic happened with the assumption that the rewrite was happening with an Opus-like model, and not with Fable. Those assumptions, at least partially, were used as arguments against the fact that the rewrite was feasible and/or a good idea.

    Clearly the model itself doesn't completely change the narrative, but at least as a note to myself, I would like to be more careful with assuming the capabilities of the models used internally by Anthropic and affiliated orgs.

  • nzoschke 18 minutes ago
    > Historically, rewrites are a terrible idea.

    This changed for me over the last 5 years.

    The first scenario was joining a company where a software product barely worked. We did the traditional incremental refactoring / rewriting, but eventually learned how rotten the core was that rewriting from first principles was the best path forward.

    The lesson learned here is that the conventional wisdom probably only applies to rewriting complex but working systems.

    Then multiple scenarios in the agentic coding age. Between day jobs and hobbies I've reproduced major chunks of complicated software like Salesforce, Gmail, Pioneer Rekordbox with very lean teams.

    Much like the blog post, the trick is to get an excellent verification loop with a compiler, linter, and test harness / test suite around the core behaviors.

    It's feeling more and more that designing and implementing comprehensive test harnesses is the real work, once you have that let the LLM cook.

  • achristmascarl 14 minutes ago
    I was fairly skeptical about the rewrite when news about it first started going around, and I still don't plan on switching anything to use the Bun rewrite anytime soon, but I appreciate how detailed and well-written the blog post is; it also seems to be primarily human-authored, in my opinion, which is refreshing.

    The most significant revelation for me was that Claude Code has been using the rewrite without much fanfare since June 17th.

  • bel8 1 hour ago
    > Claude Code v2.1.181 (released June 17th) and later use the Rust port of Bun.

    It seems the reports of Bun's death have been greatly exaggerated.

  • hansvm 53 minutes ago
    Every time I've rewritten a major project I've made it smaller and faster while fixing all the major bugs and most of the minor ones. My current team has had similar experiences. I'd be curious to see what a Zig -> Zig rewrite of the same magnitude would have done for quality.
  • Buttons840 29 minutes ago
    I've always felt [0] the people who created Bun had, as their first and foremost goal, a desire to use Zig--and that's great, I like Zig, I like when people build things their own way.

    However, I've been skeptical of using Bun, because I want a project whose first and foremost goal is to build good tools that achieve the objectives of the project.

    It reminds me of asking game developers: Do you want to build a game, or do you want to build a game engine? Building a game engine is fine, but if you're goal is to make a game, then building an engine is a poor way of achieving your goals.

    Likewise, I've wondered if the creators of Bun wanted to build better JavaScript tools, or if they wanted to use Zig.

    [0]: https://news.ycombinator.com/item?id=35970044

    • ameliaquining 19 minutes ago
      So does that mean the rewrite made you less skeptical?
      • Buttons840 11 minutes ago
        Yeah, I guess. Now it appears to be a project run by Anthropic and I'm sure the real focus is on making money--which is still slightly different than having the focus be on making the best tool.
  • ianm218 58 minutes ago
    Inspired by this project I ported most of Valkey to Rust here valdr.dev .

    The coolest outcome was being able to run a redis comparible store on an a cloudflare durable object so you do I.e. rate limiting for free with little infra.

  • frollogaston 15 minutes ago
    "I used a pre-release version of Claude Fable 5 for much of the Rust rewrite."

    It'd be interesting if Anthropic became a general software company just because they have access to models that aren't yet released, possibly export-banned.

  • himata4113 30 minutes ago
    They didn't mention the cost of this. Assuming mythos was somewhat involved I'd extrapolate this as: 128 x20 max accounts needed which comes at $25.6k or over 75k in api costs. For 75k you can hire a team of engineers that would produce a better result with sematic conversion and other tricks used in porting from language A to language B at the cost of maybe taking 1 month instead of 10 days.

    I will be a lot more excited when this is possible with <10k of api costs.

    • fps-hero 23 minutes ago
      > Pre-merge, this took 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads — around $165,000 at API pricing. By hand, I think this would've taken 3 engineers with full context on the codebase about a year, during which time we wouldn't be able to improve Node.js compatibility, fix bugs, fix security issues or implement new features. We never would've done that. The realistic alternative was to do nothing and keep fixing the bugs at the top of this post forever.
      • erichocean 17 minutes ago
        Even at $165K, it's worth it to have a better base to build on top of—especially since it didn't take a year's worth of time for three programmers.
    • incognito124 13 minutes ago
      It states $165k in the article
  • duhhhhh1212 1 hour ago
    Where is the cost breakdown? I feel like this would be the easiest number to determine and write in this post. It's hard to believe that there have been no problems/downsides since the port.
    • gpm 1 hour ago
      > Where is the cost breakdown?

      From the article

      > Pre-merge, this took 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads — around $165,000 at API pricing

      > It's hard to believe that there have been no problems/downsides since the port.

      A significant portion of the article was dedicated to the 19 regressions they've found. Starting here: https://bun.com/blog/bun-in-rust#porting-mistakes

      • BearOso 45 minutes ago
        I posted on an older article that I thought it probably cost half a million in API pricing. 165k USD is a lot lower. I wonder what the actual compute cost was. When this first hit the news, Opus 4.7 was brand new and required 6x the compute power per user token vs 4.6. The article says they were using Fable, which is way more expensive.
      • duhhhhh1212 59 minutes ago
        Thanks!! Those are solid numbers but confusing. He reported input, output, and cached input token reads but not cache writes/cached creation input tokens? Maybe cache writes aren't a thing internally?
  • didibus 32 minutes ago
    > to exhaustively come up with reasons why the changes create bugs or do not work

    My biggest issue currently, is I can't seem to get a code review that's about the simplicity of the code, and no /simplify ain't it. Removing certain bugs and generally working seems to be doing alright, especially if it's following either an example code (like in the Bun rewrite case) or a well defined "spec" of how to proceed.

  • minimaxir 2 hours ago
    Adding bespoke animations via Claude Code to the blog post is definitely thematic. It's unclear if they're useful data visualizations as they take a bit of time to parse, but they're neat.
  • pier25 35 minutes ago
    > Compiler errors are a better feedback loop than a style guide

    So essentially this whole re-write was about making Bun LLM compatible.

  • incognito124 23 minutes ago
    > In Bun v1.3.14, every build leaks about 3 MB, forever

    I'm sorry but that is insane, how was this never fixed before the rewrite?

  • giancarlostoro 58 minutes ago
    So I kept hearing that the author did this purely because Anthropic wanted a PR story, but reading this entire very well written post, with meticulous detail, what say you now? I never thought it made any sense for him to do this just because Anthropic asked him to. Sometimes you find yourself fighting the stack you're currently using, and another stack (or programming language) looks like it would alleviate a lot. LLM was just another tool in his toolbelt. I had already ported projects that were old and abandoned before using Claude Code, so I knew it was possible.
    • nozzlegear 54 minutes ago
      > what say you now?

      I think that when you have a $165,000 hammer, all of your problems begin to look a lot like nails.

      • giancarlostoro 52 minutes ago
        I've done rewrites like this, maybe it wasn't Zig to Rust, but I have been able to rewrite sizable projects, from C# to Rust before. I incorporated a similar strategy, have Claude Opus review the codebase, write a spec, then have Claude implement it, while reviewing the spec, and using the codebase as fallback and gospel over the spec. That said, it's not the entire story here as I said, there was a lot of thought put into it, it it had not been done with Claude, I have a feeling he might have started an "experimental" version of Bun in Rust instead, as many developers have done in the past before LLMs.
      • benced 45 minutes ago
        I would guess the cost to do this with humans would be _at least_ $1.5M in compensation alone (I'm thinking three 500k/year Bay Area engineers) so this is already an order of magnitude cheaper.

        Is it worth $165K? I'm less sure of that but it's honestly a moot point - this will get to 5 then 4 digits of cost pretty fast.

        • BearOso 30 minutes ago
          I think putting it in terms of API pricing is oversimplifying disingenuously. Anthropic still hasn't pulled the rug out from under us, so I'm sure it cost a great deal of money once everything comes together, likely surpassing 1.5M. Summarily, they got the result faster, which a group of engineers couldn't do, but at a greater expense.
    • johnfn 24 minutes ago
      So much of the discourse around this on HN is nonsensical, and I fully agree with you. It's patently absurd that Anthropic would demand him to rewrite Bun into Rust; it's equally absurd that they would demand any sort of stunt at all when Anthropic already pulled off the biggest stunt with Bun: running Claude Code on it. And why on earth would you cannibalize the runtime of your golden goose?
  • SergeAx 49 minutes ago
    I still think that generating a Zig-Rust transpiler would be a better approach, given all the LLM quirks, including the ability to just /goal the model with binary-identical LLVM bytecode.

    However, an open-sourced tool like that would've greatly harmed the Zig ecosystem and community.

    • leecommamichael 3 minutes ago
      Go famously used machine translation to remove dependency from C. It's a nice way to retain structural familiarity with the target language. I imagine they could've saved a large portion of that $165,000 using this route. Hard to say for certain, though. You wouldn't want to scope that transpiler at "being able to transpile all programs generally," and so scoping the project does become a serious task.
    • ivanjermakov 41 minutes ago
      > would've greatly harmed the Zig ecosystem and community

      People looking to abandon the ship first chance are unlikely to contribute much to the ecosystem and community.

  • DobarDabar 8 minutes ago
    [dead]
  • fernando-ram 1 hour ago
    [flagged]
    • gpm 1 hour ago
      1. There's no comparison - it's just showing a snapshot in time (apparently post port). You literally can't!?

      2. Of your 8 comments on this site, 7 are spamming links to this site. I at least don't think that's ok.

      • fernando-ram 1 hour ago
        Yeah, thats on me I got a little lazy. Im not trying to spam, It my project because I think its cool to see projects this way and I think it can make software more digestable and less nebulous a concept
      • fernando-ram 30 minutes ago
        fixed it
  • rvz 1 hour ago
    As expected [0] [1], this was a clear advertisement / marketing opportunity of Anthropic's Fable model on rewriting Bun (which powers Claude Code) from Zig into Rust.

    Something that would have taken hundreds of developers now took 1 developer with Fable.

    Now Claude, rewrite Claude Code from TypeScript to Rust. Make absolutely zero mistakes.

    [0] https://news.ycombinator.com/item?id=48073893

    [1] https://news.ycombinator.com/item?id=48240829

    • steveklabnik 1 hour ago
      EDIT: the parent has effectively deleted their original comment

      > 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 what I did.

      • rvz 1 hour ago
        *whoosh* goes the joke.
        • steveklabnik 1 hour ago
          Hacker News does not have a meme-y culture, and this post takes this topic pretty seriously and is technically interesting.

          It's not so much that I missed that it was a joke, I just don't think that it really added to the discussion.

          What you've edited it to is a much better comment.

          • rvz 1 hour ago
            [flagged]
            • QuaternionsBhop 55 minutes ago
              Jokes require mutual context. You failed to create a joke because you did not ensure the prerequisites were met.
              • rvz 31 minutes ago
                > Jokes require mutual context.

                The article itself is the context. Even the chatbots: ChatGPT, Claude and Gemini 'understand' the joke in the comment.

                Go ahead and ask them.

                > You failed to create a joke because you did not ensure the prerequisites were met.

                The prerequisites was for you to read the article first.

                The joke:

                "Now Claude, rewrite Claude Code from TypeScript to Rust. Make absolutely zero mistakes."

                You: ???

    • merb 52 minutes ago
      1 Developer with a 200k budget for tools.
  • classicposter 1 hour ago
    This slop rewrite introduced new vulnerabilities and regressions.
  • dfabulich 1 hour ago
    This blog post further undermines my trust in Jarred.

    He makes it sound like Claude did a fantastic Rust rewrite, and "the work continues."

    But when the Rust port merged to main, the state of the code was very, very bad. There were 13,000 instances of `unsafe`, no Miri tests at all, and, sure enough, it exposed UB in safe Rust. https://github.com/oven-sh/bun/issues/30719

    Observers could see this coming from a mile away, objected strongly to using AI to RIIR before the code merged. Rather than incorporate feedback and get the code ready for production, Jarred gaslit us all, right here on HN. https://news.ycombinator.com/item?id=48019226

    Just 9 days before he merged the Rust rewrite to the main branch, Jarred wrote:

    > This whole thread is an overreaction. 302 comments about code that does not work. We haven’t committed to rewriting. There’s a very high chance all this code gets thrown out completely.

    It's plausible that Bun's Rust rewrite is now in much better shape than it was in May. But a blog post like this would have been a place to apologize, to accept that it was a very bumpy rollout, to acknowledge that public messaging was extremely poor, and to earn back our trust.

    As it stands, I guess I'll have to run my own tests to try to evaluate whether Bun 1.4 is ready for prime time, because I just can't trust Jarred to give us a straight answer.

    • Georgelemental 58 minutes ago
      Pre-release code had bugs that were fixed before the release? Why is that a problem? That's the point of having a testing and release process
      • pier25 47 minutes ago
        what about new bugs introduced after the rewrite?
    • simonw 29 minutes ago
      > But when the Rust port merged to main, the state of the code was very, very bad. There were 13,000 instances of `unsafe`, no Miri tests at all, and, sure enough, it exposed UB in safe Rust.

      I mean yeah, that's what this whole post is about. It's about the process of going from that original state to something that's now shipping in production.

    • benced 56 minutes ago
      > We haven’t committed to rewriting. There’s a very high chance all this code gets thrown out completely.

      God forbid an engineer express uncertainty.

      • Atotalnoob 54 minutes ago
        Uncertainty is one thing, but a high chance means it’s 51% or higher to me.

        Based on that, the bun rewrite messaging was fairly misleading.

        • wccrawford 44 minutes ago
          That was their estimate at the time, based off the information they had. You can't ask more of someone than that.

          Either they estimated poorly, or it ended up the lesser portion of their estimate after all. After all, unless the estimate is 100%, there's always a chance it'll fall into the other portion.

        • jen20 38 minutes ago
          To understand your error, consider that in the month leading up to the 2016 US presidential election, the widely-accepted probabilities were between 70% (Five-Thirty-Eight) and 90% (Reuters) in favour of Clinton.
      • hansvm 37 minutes ago
        [dead]
  • tangenter 49 minutes ago
    Should we brace for another front page Zig donation announcement? A fast follow with a “Why Zig?” penance piece, replete with anecdotes about how it is the only true way to express oneself?