Section Insights
The Rise of Rust
Why are major companies switching to Rust now?
Despite Rust being over a decade old with no major changes this year, companies like Microsoft and Meta are adopting it at an unprecedented rate. This shift is driven by two key factors that influence rewrite decisions and project development.
- Rust's adoption is accelerating among major tech companies.
- The reasons for this shift are significant and may influence future development choices.
- A recent example involves the Bun project, which transitioned from Zigg to Rust.
The Cost of Rewriting Codebases
How does the cost of rewriting a codebase with AI compare to traditional methods?
Using AI to port a codebase can significantly reduce costs and time. The Bun project, for instance, spent $165,000 to rewrite their codebase in just 11 days, which is much cheaper than hiring engineers for a year to do it manually.
- AI can make codebase rewrites faster and more cost-effective.
- The Bun project exemplifies how AI can expedite complex programming tasks.
- Manual rewrites are often more expensive and time-consuming.
Performance Gains from Rust
What performance improvements can be expected from rewriting in Rust?
The transition to Rust has resulted in significant performance enhancements, including a 2x increase in general performance and up to 100% faster execution on heavy workloads. However, initial versions may require human intervention to optimize performance.
- Rust can lead to substantial performance improvements over previous languages.
- Initial rewrites may not perform well without human optimization.
- AI can assist in the initial coding, but human refinement is still necessary.
Broader Adoption of Rust
What are some examples of companies adopting Rust?
Companies like Meta and Microsoft are increasingly adopting Rust for various projects, including porting the React compiler and integrating Rust into the Windows kernel. This trend indicates a broader acceptance of Rust across the industry.
- Meta is using Rust to modernize its core messaging libraries.
- Microsoft has integrated Rust into the Windows kernel for improved performance.
- Rust's adoption is becoming a standard practice in major tech companies.
AI and Rust: A Perfect Match?
Why is Rust a suitable language for AI-assisted programming?
Rust's compiler is highly effective at catching errors, making it an ideal candidate for AI integration. The combination of AI and Rust allows for efficient error correction and code refinement, enhancing the programming experience.
- Rust's compiler helps identify and fix errors effectively, benefiting AI processes.
- AI can autonomously address compiler errors in Rust, streamlining development.
- Despite its advantages, Rust may not be the right choice for every developer due to its complexity.
Transcript
0:00 So Russ is over 10 years old. Nothing about the language fundamentally changed this year. There weren't any big releases or major breakthroughs. And yet all of this happened in the past 12 months. Companies just keep switching to Rust. And I'm not talking about little startups. I'm talking Microsoft, Meta, Cloudflare, the type of teams that said no to this exact rewrite 5 years ago because it was too expensive. And then this year something made all of them switch to Rust at the same time. And once you see what that something is, well, it's kind of two things. It changes how you think about your own rewrite decisions moving forward. And with what feels like an entire industry shift towards Rust, also deciding whether or not you just build that new project with Rust to begin with. Now, you've probably heard about one of these already. Everybody covered this one, even me, when it first happened. But back then, all we really had was the code and some bits of information here and there. Just our own speculation.
0:58 Now, I'll still assume that some anthropic marketing was at play here. Whether it was one of the reasons or just a happy accident, we'll never know. But now that Jared finally released the blog post about this rewrite, which took longer than the rewrite itself, well, we have a whole lot more information. And I want to dive into this story first because it's a very good example for the rest and with a lot more available information. If you missed my full video on the bun rewrite from Zigg to Rust, well, here's the short of it. Bun is a very popular JavaScript runtime among other things and was one of the most prominent Zigg code bases ever written.
1:36 That is until Jared, the founder of Bun, performed a little experiment back in May using AI to port the entire codebase to Rust. And that's all it was at first, an experiment. Bun had just been acquired by Anthropic in December of 2025. So now Bun has access to infinite tokens to do things like this. But that experiment quickly turned into much more. It got merged into the main branch with an announcement of Bun fully moving away from Zigg into Rust. The reason being because the RAW port, even before any cleanup, passed Bun's entire test suite. It also fixed a bunch of memory leaks and flaky tests and came out both smaller and faster than it was before.
2:19 And the blog post finally gives the full picture or at least what they're willing to share with us. I mean, just look at the quote small sample of bugs they fixed by switching to Rust. He keeps after free crashes. Memory leak. Memory leak. Memory leak. Grace condition. Yeah, they they had a couple bugs. And a reason for that is because bun sits on top of JavaScript core which is garbage collected whereas Zigg's memory is manually managed. So mixing those two ways of working with memory led to leaks and crashes. So it's not that Zigg's bad and Rust is good. It it depends on your exact use case. And for Bun, it seemed that Rust may be the best choice for theirs because back before this entire rewrite happened, Jared was looking at Rust and realized that actually a large percentage of these bugs they were having in bun would actually be caught as a compiler error in Rust instead of making it to production. But there's just one glaring issue here, and that is bun has 535,000 lines of zig code. You can't just port it to another language like Rust on a whim. You would have to put together an entire team of engineers, taking them away from improving Bun and fixing the existing bugs to have them hack away at this port for at least an entire year in hopes that it pays off. So given that fact, Jared figured their best bet to fix stability issues was to add Rust inspired smart pointers to Bun's existing Zig codebase. But admittedly, that's not really the best way to go about things because homegrown smart pointers like these offer worse ergonomics than what Rust has and with none of the guarantees. But wait a minute, times are a little bit different now. We don't need to hire full teams to prototype something when we can have AI do it instead while we work on anything else. So, how about just having Claude rewrite Bun in Rust in this new unreleased model that we now know to be Fable 5, which if you haven't used it, watch my video going over how it codes.
4:19 It is really good at looping and iterating through itself and the code that it writes until it gets through the entire project. Now, this port wasn't just a simple prompt of rewrite bun from Zigg to Rust, but a much more thoughtful approach, not so dissimilar as how you would do it with an actual team of engineers. And there is a lot of good information to be extracted here about how they did it for those of y'all who are considering doing the same. Which if you are, Curser, the sponsor of this part of today's video, would actually be a really good way to go about it.
4:54 Especially with their cloud agents where you can delegate entire engineering tasks, even one like this, to agents in the cloud where they run in their own remote development environments with the tools, the dependencies, and the context they need to build, test, debug, and complete work all on their own. And cursor of course is good for any type of development work not just you know porting an entire codebase but whatever work you're doing you can check these cloud agents from anywhere from your laptop that you can now fully close and have your agents continue to run from your phone with the official Cursor mobile app especially if you work on a desktop like me that isn't necessarily the easiest thing to carry around or even on your iPad because cursor just launched their iPad app and what's nice about these cloud agents is that they return videos and screenshots shots, logs, and test results. So whether you're checking it from your phone or elsewhere, you can verify what they're actually doing. And I do want to highlight something. What harness you use to code actually matters. We're always comparing different models and how good they are, but your harness is just as important. And Cursor is undeniably one of the best. I know I'm being sponsored by Cursor right now, but I'm not sharing my opinion. I'm just stating the actual information based on the data we have available showing cursor as one of the best that utilizes AI models better than basically every other. So if you want to give it a shot, just click on the link in the top of description or go to jetty.2/cursor.
6:18 So rewriting an entire codebase has never been easier, faster, or cheaper. And yeah, you may have seen that this port costs $165,000 at API pricing, which they spent over the course of what, 11 days. So, I see why at first glance a lot of folks said it was expensive, but it's really not. Jared says he thinks doing this by hand would have taken three engineers with full context of the codebase about a year. And the last time I checked, the average salary for a software engineer at Bun was about the same, $160,000.
6:53 Now, multiply that by three, look at the time, any other potential resources being used, and you can see just how cheap this port actually was. And I actually think Jared was being a bit optimistic here because Dropbox, for example, took four years and about six engineers to rewrite their sync engine. Now, that was quite a bit more complicated since it wasn't a 1:1 port. They reinvented their entire architecture from scratch. But still, it took four times longer and twice the amount of engineers as Jared's estimate.
7:26 Or if you want to look at a closer example, we can take a look at Typescript's port to go and that took about 5 to eight engineers about 2 years. So, with just three engineers, I would be very impressed if they could get it done in just a year. And then you have AI with just one guy controlling it take 11 days. And I know we're on a hyonic treadmill here. We're desensitized to hearing things like that. But when you sit down and really think about what that did, it's insane.
7:56 It is very impressive. And I feel like this is a good time for my obligatory mention. I'm not trying to hype up AI. I'm not trying to be optimistic or pessimistic about AI. I'm trying to see AI for what it is and what it can do, which in today's day and age is a lot. And here's the thing. If Bun was just a one-off story, I mean, that's a really cool story, I suppose, but it's not.
8:20 There is a much larger pattern happening throughout the industry right now like Meta who just did something nearly identical with their type checker called Flow which is effectively their alternative to TypeScript which you have probably used before without ever knowing it because React is written with it. Now Flow itself is written in this old beautiful language called Okamel which is genuinely a great language for building things like this. However, there aren't many OAML engineers out there for hire, and Meta's internal JavaScript monor repos were hitting scalability walls that O'Camel's runtime just wasn't going to solve. At least, this is what they said back in 2019 when they first flirted with the idea of a full port. And for this port, they wanted to use Rust. But what's interesting is why they chose Rust.
9:12 Because if we look at a bit of a counter example like the TypeScript port to Go, one of the reasons they chose Go was because it was easy to port, very straightforward. Rust, however, was the harder port for Flow coming from Okamel because Okamel is garbage collected. So a natural choice for a language would be Go or even Cotlin because all three of these languages use what's known as a mark and sweep GC strategy. But the team decided against those languages which were actual considerations as laid out in the initial article and they decided on the more risky rustport because they wanted to be in the ecosystem where the JavaScript tooling was already going SWC roll down biome that whole world because it provided them with more integration opportunities. This was all considered back in 2019, but they decided to shove the idea simply because the entire rewrite was just way too expensive. Fast forward to 2026, and would you look at that? It's a whole lot cheaper to do something like this. So, by utilizing AI to reduce the cost and the time to make this sport, they actually did it. They ported their static type checker from Okamel to Rust and saw a roughly 2x general performance increase and up to 100% faster execution on heavy workloads. So, it paid off. But what's a little bit different in this rewrite than in Bungee rewrite is that when it first got done with the rewrite, it didn't work. And then the first time the full Rust version ran, it passed zero tests. And then once they made a little bit more progress, they found that the Rust version was actually slower than the O camel version. That is until humans went in and fixed the allocation patterns. You see, it's not just a simple human out of the loop rewrite. is just that AI can heavily expedite the process and do a lot of the grunt work where humans come in and refine a little bit like all of the unsafe blocks in bun, but I already harped on all of that in my previous video, which is why I didn't really bring it up yet in this one. And my favorite little tidbit of information that I found while making this video and researching and all of that is that the first ever Rust compiler was actually written in Okamel.
11:34 So now it's kind of one of those, you know, student becomes the master type of deals where now Rust is replacing O camel in various code bases like Flow. Anyway, this is actually not even an isolated event within Meta either. There is a much larger Rust adoption going on within the company. They ported the React compiler from TypeScript to Rust. And like the bun example, this just started out simply as an experiment, which just recently got merged. They're rewriting decades old C code that is in one of Meta's core messaging libraries in Rust, which touches Messenger, Facebook, Instagram messages, and I'm sure various other points within Meta.
12:13 And the main reason for it is because it is just getting so much cheaper to do things like this, to experiment with potential ports to see if that is a viable solution to the issues you're having with the existing programming language. And then for all of these examples, they just found Rust to be the best programming language for their use case. And sometimes you don't need to rewrite anything in Rust to get the benefits of it. For example, linear, they use the build tool called VIT. And in VIT 8, they swapped out their bundler for rolldown, which is written in Rust.
12:45 And Linear's production builds went from 46 seconds to 6 seconds. And with this same change, ramp cut their build times by 57%. Mercedes-Benz cut theirs by up to 38% and Beehive cut theirs by 64%. So, in other words, choose your dependencies wisely because that's all it was. And these companies without doing anything other than normally upgrading their dependencies saw incredible performance boosts. Now, I got to mention something that is very important is longevity and whether or not decisions like these play well long-term and not just serve a short-term purpose. For example, I made a video about how these companies performing layoffs, citing AI as the sole or primary reason for these layoffs are pretty much lying to you. And it's not an opinion piece. I mean, I I don't I'm sure I share my opinion throughout it, but I dove into the filings, looking at their finances. I checked their old memos and their new memos and saw what they said elsewhere and the actions that they were actually performing outside of this announcement and just a litany of other things to come to the conclusion that I did. And one thing that I pointed out in that video is that some of these companies had done it early 2025. They laid off a whole bunch of people, whole bunch of positions saying AI is going to fill their jobs. And then fast forward to today, you see that well they're hiring for those jobs once again. it it didn't go in their favor whether they believed it was actually going to happen or whether they were lying to make it sound good to investors. And as always, time will tell. So, how are these older rust ports doing? The ones that I talked about in last year's video. Well, one is a little small project called the Linux kernel. You may not have heard of it, but there's been some developments there. I'm not sure if you remember last year there's this whole drama going on. It was about a maintainer calling Rust a cancer to the Linux kernel and people resigning over it and all that stuff. Well, in December at the kernel maintainers summit, they officially announced the Rust experiment concluded, done, but not done with Rust. The conclusion that they came to is Rust is going to officially be a part of the Linux kernel. Or as they said it, Rust is here to stay. But it goes deeper than that because very recently at Rust Week, longtime Linux kernel maintainer Greg Crowa Hartman, the guy who runs the Colonel CVE team and has been involved with probably every colonel security bug of the past 20 years. Well, he got on stage and showed a new Rust type he's been developing called Untrusted, which I'll spare you the details, but if you want to learn more about it, I highly recommend watching his talk on it. But what he says is that it could eliminate 80% of the CVEes that the kernel generates. And unlike a cancer, I personally think this is going to be a good thing, which obviously cancer is not. Now, this is one of my favorite examples because it it takes the extremes of the C developer and now they're adopting Rust. That's like them adopting AI, which actually now they are as per Linus himself. Another update, Microsoft. Like Meta, they too have continued to adopt Rust in other parts of their software. Last year, we talked about how they used Rust for font rendering, and now there's Rust running in the actual Windows kernel. What you think about Windows and its kernel is irrelevant here. I'm talking about Rust adoption. Hopefully, Rust can help.
16:13 Another I've talked about is Cloudflare replacing their core proxy, which was an EngineXbased system that's been fronting a huge chunk of the web for over a decade with a Rust one called FL2 and websites got 10 milliseconds faster at the median as a result. There are a lot of other callbacks I can make, but I want to take a look at more new examples specifically from the AI labs. Because if an AI lab is using a specific language, chances are they're going to prioritize that language when they're training their models, therefore making AI better at programming in that language, which I think we've already seen with Rust. Whether it was intentional or not, AI is pretty dang good at Rust. If you haven't used it in a while, it's made some strides. So, OpenAI, they rewrote their entire codeex CLI from TypeScript to Rust. And if you think TypeScript is a crazy language for a CLI, Open Code, which a lot of people love, is written in Typescript. And then OpenAI acquired Astral, which is Rust tools. No, it is Python tools that are built with Rust. You may have heard of UV, you may have heard of Rough. Those were built by Astral. And I would imagine this acquisition was because the tools are top tier and they have their own reasons as to why they would want to bring in this type of tooling. But I can't overlook the idea of a potential aqua hire in play here as a partial reason for the acquisition since Astral had really good Rust engineers that OpenAI moved to the Codeex or I don't know I could just be looking into this a little bit too deep but that is what they did. And then we have SpaceX AI, as it's now called, open-sourcing their Grock build CLI. And would you look at that? Written in Rust. And unlike Codec CLI, this is not a rewrite. This is just them building their product in Rust to begin with. And I've heard some people call the Grock build code sloppy written. But I disagree. Obviously, they used AI to write it. So if you're saying everything AI writes is slop, then okay.
18:14 But that's not really the definition of slop. But at the same time, even if it was, I wouldn't call it poorly written. But the thing is, even if it was poorly written code, the end product doesn't reflect that. It's a good product. Well, except for the part where Grock build CLI would secretly package your entire repo and upload it to their own cloud bucket. That wasn't good. And it's been backtracked and supposedly all the code that went up there has since been deleted. But I don't like that. I I don't like that at all, actually. You know what else I didn't like? how XAI replaced my beloved Scola and Java algorithm with a Rust algorithm. And I didn't like it for no reason other than just the idea of Java being replaced, which I understand I am in the minority here. Well, that that's not actually true. I'm not I'm not really upset, but I got to play the part at least. And I made a whole entire video on that.
19:06 Looking at the old codebase, looking at the new codebase, really breaking down this entire rewrite. So if you want to learn more about it, there's that video. But basically the orchestration layer, the post store, the serving pipeline were all written in Rust and just tied together everything for the brains of the algorithm which was their grobased ranking model called Phoenix. So AI AI is the brains behind the recommendation algorithm on X with Russ tying it all together. So I understand I get carried away with all of these case studies. I just find all of them fascinating and I want to share them. But what does it all mean? Well, the reason why everyone keeps switching to Rust is twofold. One, because it's actually viable now with the sole factor for that being AI.
19:56 There's no two ways about it. That's the thread I have been tying from case study to case study throughout this entire video. Rewriting reporting an entire codebase almost never made any sense. It was too complicated. It was too expensive. It was too timeconuming and for all of these the potential payoff just wasn't worth it. It just didn't make any sense until now because now you can have one or two engineers driving AI having AI do the vast majority of the work to experiment on all sorts of things. Maybe potentially porting or rewriting code that you never thought of before and doing it at a fraction of the cost in the speed that it would have taken you just a few years ago. And two, the second fold and why everyone keeps switching to Rust is because Rust is just a really good programming language for reasons that I sprinkled throughout this video for why these companies actually switch to Rust instead of all other languages, despite it sometimes being the more difficult and less convenient choice even with AI. And actually, here's the real reason why Rust and AI go so beautifully together.
21:04 When Bun's port hit around 16,000 compiler errors, they had 64 clawed agents looping on cargo check overnight, fixing them file by file, completely autonomous at this point. So instead of you checking the AI's work every step along the way, the Rust compiler was doing it for you, giving that feedback to AI and having AI continue to loop through until all of those errors were properly addressed. And Rust compiler, as annoying as it is sometimes, well, it catches more kinds of mistakes than any other languages compiler that I've ever used, which is why it is a fantastic candidate for AI. Now, before you go and rewrite every single project you have within your company or your side projects in Rust, I have to give the caveat the same type that I did in the past video is that Rust isn't a magic bullet. For example, right after Bun left Zigg, Mitchell Hashimoto, who is the founder creator of Ghosty among other things, but Ghosty is written in Zigg. He said he had evaluated Rust for Ghosty, but chose Zigg for a few reasons. From a developer standpoint, he just found Rust too complex. He simply doesn't like using it.
22:20 >> It's very superficial. I just when I write and read Rust, I'm not having fun. You know, it it's very much a stylistic choice. Now, I know plenty of folks who feel the exact opposite and love coding in Rust. So, this here is really personal preference, just like how some other devs hate Rust solely due to the fact that they don't like waiting for the compiler. So, instead of waiting for things to compile every single time they want to change something, they chose Go instead. But also, there were technical elements that made Zigg a better choice for Ghosty, like C interoperability.
22:53 Zigg does this really well. I wanted to to get back to systems programming, but I I I recognized the warts that C had and I was looking for a better C. And Zigg to me always felt like that. And years into using Zigg, I feel the exact same way. Whereas we saw with Bun, not so much. Every bit of C and C++ is FFI with unsafe blocks and binding elements. So, it does handle it and address it fine, but it's not optimal if this is an important thing for your codebase. But due to this, Bun's codebase has about 4,000 permanent unsafe blocks that they can't do anything about. And then there's your preference on memory management.
23:33 Mitchell prefers explicit memory management because he wants to be able to make intentional allocation decisions without having to negotiate with Russ Borrower. So while I do see an incredible amount of momentum in the industry where more and more huge companies and small companies but particularly huge companies are choosing to write and rewrite code bases in Rust, I needed to add in this caveat by saying it's not the magic bullet. It's not always the right choice, but for many it finally is an actual choice because Rust isn't what changed this year. the cost of rewriting and switching to Rust is what changed and that's the real reason why so many have been changing to Rust over the past 12 months and really most of these examples have been just within the past few months. But one more thing before I go which I think is very important. There are a lot of other Rust rewrites that I didn't mention. There's pseudo, there's core utils, there's a lot of what you could call the internet's plumbing. These are a lot of tools and a lot of code that almost every single one of us depends on, but nobody really owns it. Not a lot of money being made on these things, if any at all. So that begs the question, how are these tools getting funded to completely rewrite their codebase from whatever language into Rust? Who's paying for these rewrites? Some big tech, others a little bit of government involvement more or less forcing these rewrites, not a complete mandate like ADA back in the day. And now that we know that, the big question is why, but that is a whole another topic for another video if it ends up shaking out.
25:28 So, if you're interested in that video, subscribe to the channel and let me know. But that's all I got for you for today. Y'all have a good one.
Summary
- Major companies are increasingly adopting Rust, moving away from languages like Zig and OCaml due to performance and stability benefits.
- The Bun project exemplifies this shift, where an AI-assisted port from Zig to Rust resolved numerous bugs and improved performance.
- AI tools can significantly reduce the time and cost of rewriting code, making previously daunting projects feasible.
- Companies like Meta and Microsoft are also rewriting critical components in Rust, citing better integration with existing JavaScript tooling and performance improvements.
- Rust's compiler helps catch more errors, making it a favorable choice for AI-assisted development.
- Despite the momentum towards Rust, it is not universally the best choice; developer preference and specific project requirements still play a crucial role.
- The cost of rewriting codebases has decreased, making Rust a viable option for many companies that previously deemed it too expensive.
- The funding and support for these rewrites often come from large tech companies or government initiatives, raising questions about the sustainability of such projects.
Questions Answered
Why are major companies switching to Rust now?
Despite Rust being over a decade old with no major changes this year, companies like Microsoft and Meta are adopting it at an unprecedented rate. This shift is driven by two key factors that influence rewrite decisions and project development.
How does the cost of rewriting a codebase with AI compare to traditional methods?
Using AI to port a codebase can significantly reduce costs and time. The Bun project, for instance, spent $165,000 to rewrite their codebase in just 11 days, which is much cheaper than hiring engineers for a year to do it manually.
What performance improvements can be expected from rewriting in Rust?
The transition to Rust has resulted in significant performance enhancements, including a 2x increase in general performance and up to 100% faster execution on heavy workloads. However, initial versions may require human intervention to optimize performance.
What are some examples of companies adopting Rust?
Companies like Meta and Microsoft are increasingly adopting Rust for various projects, including porting the React compiler and integrating Rust into the Windows kernel. This trend indicates a broader acceptance of Rust across the industry.
Why is Rust a suitable language for AI-assisted programming?
Rust's compiler is highly effective at catching errors, making it an ideal candidate for AI integration. The combination of AI and Rust allows for efficient error correction and code refinement, enhancing the programming experience.