Theo-brainUnofficial. Not affiliated with Theo or t3.gg.
Sign inYou
47:40
0:00

You can rewrite typescript in rust for $420k

Saturday, Oct 10 · 48 min · about 10 min to read

Theo-brain watched all 48 min

Theo had AI agents rewrite TypeScript's compiler and type checker in Rust. Codex got stuck near 84%; Opus 5.5 finished in two weeks by porting from Microsoft's Go version. His real goal is not speed: Rust packs into WebAssembly, so an agent's whole build-and-check loop could run inside a cheap V8 isolate instead of a costly virtual machine.

Skim itWatch the port story, the in-isolate demo and the prompting section; the history lessons and the Cloudflare explainer are covered well enough here.

Parts

Announcing TS-Rust

He unveils the agent-built Rust rewrite and teases catches and a secret reason beyond speed.

But there are catches to all of this. From how I built it to how I verified it to the secret reasons I actually wanted this to exist, which believe it or not aren't just RAM usage and how long it

Why type checking is the hard part

Turning TypeScript into JavaScript is easy; checking the types is the slow, complex part.

of a deal. Checking the TypeScript to make sure it's correct, way harder and also way slower. This ended up being where most of the time was spent. As a

Why Microsoft chose Go

Theo, a self-described Go hater, defends Go as the right language for Microsoft's rewrite.

also the creator of C#. I have the hot take that Go is the right language for this. I know everybody else has opinions, but let me explain why. I recently got

Inside the port

Opus ported Go's own standard library to Rust, which first made the result slower than Go.

Go STD. This is the standard library from Go ported to Rust. Because the way Opus chose to do this wasn't to rewrite things from Go to Rust. It was to go through this Go port line by line and faithfully port it over to the Rust language. And the result of this

Benchmarks vs TS Go and Bun

On his T3 Code project, TS-Rust beats TS Go and Bun check once the Effect checks are included.

Code. So, for our use case in T3 Code, not only are we way faster than TS7 with Affect's TS Go plugin, we're actually way faster, like four-ish times faster than Bun as well. Not because Bun check

The silly reason and the real one

He built it because models couldn't, but mainly because Rust compiles well to WebAssembly.

little easier to extend and play around with. But, the main reason little thing called WASM. This goes back to the garbage collection bit we talked

Cheap AI, pricier computers

AI model costs are falling fast while renting the machines agents run on gets pricier as AI soaks up RAM demand.

The cost of inference is going down, and it's going down rapidly. What about the cost of compute? What about the cost of VMs? See where I'm going here? The cost of renting a 16 or 32 gig box is going up steadily thanks to AI sweeping all the demand for RAM. The result is that

How Cloudflare isolates work

Cloudflare runs many customers' code in shared V8 isolates instead of separate Linux machines.

instance effectively that is running with our code in it. On Cloudflare, your code and my code are executing in the same instance of Linux, just split higher up in the V8 layer instead of with VMs and Docker. Hopefully this all

The in-isolate demo

An agent builds and type-checks an app entirely in memory, which he says could run in a Cloudflare Worker.

This will still run exactly the same. That is what makes this demo cool. It would be fully possible to run this entire demo in a Cloudflare worker. So instead of needing half a gig of RAM and a bunch of reserved CPU, I can throw it in here and it costs nothing. Another

The prompts and the real work

His prompts were simple; the work was fixing the agents' environment, like a manager.

once we did, but my energy was honestly similar to how I work as a manager, where I wasn't spending my time in the trenches writing code. I was spending my time making sure that my team had everything they needed to be as effective as possible in finding where

Course plug and closing thoughts

After a plug for his paid course, he says he can now test long-held wild ideas just by asking Opus.

the future. Now when I have one of these insane ideas, I tell Opus and then I see if it works or not. Even now, I wanted to see if this will actually run on Cloudflare. So I just told Opus, go do it. And it probably will. Absolutely

Tap any time to jump the video there.

Key takeaways

Model choice decided the project. About $400,000 of OpenAI Codex tokens over months got nowhere, topping out near 84% compatibility. About $20,000 of Anthropic's Opus 5.5 finished it in two weeks. Theo says he never read a line of the code.

working on for 5 months now. I burned $400,000 of Codex tokens and got nowhere. I burned $20,000 of Opus 5.5 and I got there in 2 weeks. Important note, I have not read a single line of code.And it was. The furthest I got using OpenAI models was roughly 84% compatibility. And while like impressive

The port worked because it went through Microsoft's Go version, not the original JavaScript. Microsoft's team had hand-ported TypeScript to Go. Theo's agents then did the same step from Go to Rust, which is a much easier jump.

This happened because Go was a much better starting point for a Rust port than JavaScript is. The Microsoft team faithfully by hand went through every line of code in TypeScript, ported it to Go, and then started refining it to make it better and faster in Go. My agents did the same thing from the Go version to Rust, and they succeeded. I didn't

It is a faithful drop-in replacement. Of six bug reports so far, five were bugs in official TypeScript 7 that got copied over. It runs about 2x faster than the Go version and 13x or more faster than the old JavaScript one.

have been opened total so far, one of them was specific to TS Rust. The other five issues were problems that exist in TSC 7, the specific version that we were targeting. So these aren't things that are wrong with the rewrite, these are bugs in TypeScript itself currently thatitself. And the improvements we see here for most of this stuff is 13x plus for going from TSC 6 to TSCRS. And it's usually a 2x improvement from the go version. But ready for the spicy take

Theo's main reason for wanting a Rust version was WebAssembly (WASM: code packaged to run inside a browser-style engine). He says WebAssembly is not a good fit for Go, so TS Go wastes a lot of resources there, while it is an incredible fit for Rust.

with. But, the main reason little thing called WASM. This goes backpennies. And doing this with Go would suck because TS Go wastes a ton of resources simply because porting that to JS is not viable Wasm, but you get the idea. WebAssembly is not a good fit for Go. It is an incredible fit for Rust.

His demo: an agent builds and runs a full app entirely inside a V8 isolate (the sandbox Chrome and Cloudflare use to run JavaScript). Agent, compiler and app together used under 216 MB of RAM and peaked around 4% CPU, and it works with the disk set to read-only.

everything else, just ran on my isolate and used under 216 megs of RAM and it peaked at like 4% CPU.What I built here is impressive because I could turn my file system on read only and it still works. Nothing here left RAM. Nothing here left V8. I'm not doing anything on the system. This all exists within V8. The whole dev loop exists in

Three skills here are new to you.

Long-running goal with a hard finish line New

What it is
Give an agent a standing goal with a measurable target and tell it to keep going until it hits that target, rather than a vague 'improve this'.
Why Theo cares
After reaching full compatibility, his agent kept making one speed fix and declaring victory. Setting 'minimum 2x faster than the Go build' kept it working for two weeks until it got there.
How to try it
  1. Pick one number that defines done, such as a speed, a pass rate or a size.
  2. Write the goal as 'our target is X; continue iterating until we get there.'
  3. When the agent stops early, tighten the end state instead of re-prompting the task.
performance." So it needed a better end state. So I told it with a new goal, "Our target is minimum 2x faster than the go build. Continue iterating until we get there." And then it did for 2 weeks.

Fix the environment, not the prompt New

What it is
Run separate threads that watch the working agents, find blockers and repeated failures, then change their setup so many agents can run in parallel without colliding.
Why Theo cares
He says his prompts were trivial; the results came from removing bottlenecks. When the agents kept running out of compute, he gave them SSH access (remote login) to other machines he owned.
How to try it
  1. Keep a second agent thread auditing what is slow or failing over and over.
  2. Ask for multiple sub-agents working independently, and note in the agents.md file how they avoid stepping on each other.
  3. If the agents keep running out of compute, give them access to more machines.
Real talk though, the things I did here were not around the prompts. It was around the environment and setup to allow it to do this stuff. So I like I had other threads going where I was auditing constantly figuring out where the blockers were, what's taking a
out of compute all the time. So I took other machines I had in my fleet, configured them for SSH access, and told it, "You have SSH access to other machines now, like cup two and Alvin two of my uh VPS's." I noticed it kept

just-bash New

What it is
A library by Malte at Vercel that gives agents a fake bash command line in memory, with a fake file system and processes, so the agent acts as if it had a real computer.
Why Theo cares
It lets agents explore files without a real machine. On its own you can't build a real app with it, because you still need a TypeScript compiler; TS-Rust fills that gap.
How to try it
  1. Ask your agent whether just-bash could replace a full VM for agent tasks that only read and search files.
of just-bash is to provide agents a full fake bash environment in memory in JavaScript so that you can import this bash from just-bash and then execute most traditional bash commands with a fake file system, fake processes, fake everything, allowing for an agent to operate as though it is working within

Advice

For almost everything, Theo recommends Bun check over his own TS-Rust, because he has more faith Bun's will be maintained. The trade-off: Bun check raised incorrect errors on Sentry's and tRPC's code, so on big, complex codebases he trusts TS-Rust's checking more.

code base, if I recall. Bun also raised incorrect errors on Sentry and tRPC. So, the Bun checker, while incredibly impressive and faster in a lot of cases, does not have faithful enough checking for me to trust it in these types of big projects. I think Bun check fits wellis a great solution. I actually honestly would recommend Bun check over TS Rust for almost everything simply because I have higher faith it'll be maintained, but TSCRS, my project TS Rust, is a way

Hot takes

Theo calls it a hot take: Go is the right language for rewriting the TypeScript compiler, even though Go is the wrong choice for a web service that must respond as fast as possible.

His reasoning: For taking slow JavaScript tooling that runs for minutes, cutting that time down and adding concurrency (doing many things at once), he says Go is one of the best languages.

also the creator of C#. I have the hot take that Go is the right language for this. I know everybody else has opinions, butwas building a web service I wanted to have respond as quickly as possible, Go is not the right language. But if I'm trying to take something written in JavaScript that's really slow that takes minutes to run and shave the time down and get more concurrency, Go is one of the best languages to do this with. But

The free cloud computers that tools like Cursor give agents won't last; compute will become the constraint when building with agents.

His reasoning: Rented machines are getting 25 to 30% pricier a year as AI soaks up RAM, while AI model costs fall 10 to 100x a year, so the machine will soon cost more than the model.

So, one of these things goes up by 25 to 30% every year, the other goes down by 10 to 100x every year. We're going to quickly get to a point where inference is cheaper than the VM. With a modelwhich point, compute will be a constraint for when we're building with agents. Right now, we're being given the VMs for free, but that is not going to last. Even Cloud Code isn't doing this

Cloudflare isn't cheap to win customers, and Vercel isn't overpriced to make more money. Their prices reflect what each platform actually costs to run.

His reasoning: Cloudflare runs everyone's code in shared, lightweight JavaScript sandboxes instead of giving each customer a separate Linux instance.

it's so cheap. It's actually cheap to run. They're not just pricing things cheaper because they want to win. They're doing it because their platform allows them to and still have margin. In this sense, Vercel's not overpriced because they want to make more money than Cloudflare. They are charging

Anyone who still doubts AI-driven development is the future 'deserves the lack of employment' they'll have in three months.

His reasoning: A YOLO project like this shouldn't even pass the tests, yet it works as a drop-in replacement for TypeScript.

yeah, if you still think AI dev isn't the future and isn't obviously where all of software dev is going, you deserve the lack of employment you'll have in 3 months because this is insane. It's

How Theo thought about this

He uses an 'impossible' task as his yardstick for new models: he picked this port precisely because models couldn't do it. Now that one did, he admits he is running out of tasks that are too much for them.

have guessed. I did it because I didn't think models could and now that they can, I'm running out of things to throw the LLMs at. Like, I don't know what

He refused to judge the project by its $420,000 headline. Only the $20,000 of Claude work mattered, and on his subscriptions that was about 10 weeks of one account's limit, which he calls money well spent.

And I am To me, this is money well spent. I know that seems insane because the 20,000 or the $420,000 headline number sounds crazy, but with the subsidization from a subscription and the fact that only the 20K of Claude mattered, this being 10 weeklies of usage is just uh hilariously good value

Sign in to mark what you've watched and keep notes.

Have a question about this one? Ask about this video →

Theo Daily is unofficial and not affiliated with Theo or t3.gg. Written by Claude Opus 5.5 from each video's transcript.