179 comments

[ 0.21 ms ] story [ 16.5 ms ] thread
According to voidzero, this port is up to 8x faster than TS 7.0 & ~70% less memory.

Microsoft should seriously consider porting typescript to rust at this point

Idk. Apart from the fact that benchmarks are generally of questionable value, what's the point? Is the TS compiler unbearably slow?
They say the point in the article - WASM
> Is the TS compiler unbearably slow?

It's not. Even the JS compiler is still fast enough for many projects given the single core improvements in hardware (eg Apple Silicon).

I'm pretty sure they already considered it before settling on Go. Allegedly, they chose Go because it was easier to translate to.
That was pre-AI. Ironically if they waited just another year they could've done this port directly to Rust themselves.
Not really because this port is based on the Go version. I doubt it would be as easy for an LLM to port the TS 6 codebase.
The Go version was a line by line port of the TypeScript version.
after 7.0, tsgo version is The canonical version. so, there is no other choice here
Up to 8x faster seems kinda of a crazy claim. 8x faster at what?! TS 7.0 is reasonably well optimized and compiles VSCode in well under 10 seconds..

This can type check and compile VSCode in less than a second?

For VSCode: 4x speedup vs TS 7, 3x vs TS 7.1
So that's three now. This, tsgo-rs, and `bun check`
They mention in the post they are working with Theo to absorb tsgo-rs into tsrs.
Why would they bother merging his vibe slop if theirs is better?
so this is software now?

youtuber vibe codes a transpiler says they're not going to bother maintaining it - but big company like cloudflare takes it seriously enough to absorbe into their own official services.

What is happening?

What is even software dev anymore?

What didnt the labs or cloudflare do this themselves, I mean they did, but then if it's all vibe coded, why do they need someone else's vibe coded stuff?

How is any of this serious?

> why do they need someone else's vibe coded stuff?

Because even if vibecoded, the initial work has already been done, and it would be absolutely foolish to outright dismiss it just because it doesn't meet puritanical standards.

> How is any of this serious?

It isn't & shouldn't be. The upfront demand for "serious" is what kills public projects in the first place, where they all come from an experimentation perspective.

There is no public project out there that (from its first commit) was fully serious: Each & every one of them were offshoots & experiments, testing to see if the thing was possible in the first place.

(comment deleted)
These days the trend seems to be rewriting everything in Rust.
I'm staying stainless
Did you know? Even stainless steel RUSTs in sea wind.
You should say you're staying fungal infection free as it's named after the Rust fungus not the chemical reaction even if that's what people think these days.
It's exciting to see the speed gains. I use TypeScript every day on a large codebase, and it is too slow to run locally. I don't love this change though:

> However, frontier AI models can now do large-scale ports almost independently in a matter of days

> I wrote zero code. Not "barely any". Zero

So we are going to move from a carefully handwritten port to an entirely AI-generated port. I know this is the way the industry is headed, I use coding agents a ton. But I still review their output because they often don't make sound architectural decisions. Maybe this is a sign that my way of working is going away. I'm not sure how to justify that kind of time spent when someone can do the same thing in a matter of days with barely any effort.

I am working on my own language now, I've spent most of this year on it. The idea that someone could just replace it in a matter of days is wild. Wonder how the TS team at Microsoft feels about this.

> The idea that someone could just replace it in a matter of days is wild.

They didn’t design a language that millions of human engineers enjoy (?, lol) using. They took an existing codebase and ported it. Yes, the porting part is easier now but only because another project and spec exist.

While this is true - and I see the same sentiment as i am about to make ad nauseam - it is kind of amazing how far the goal posts have moved in such a short space of time.
It’s not a goal post. It was literally a fucking benchmark of the very first LLMs.
sorry, can please explain this? which benchmark are you referring to?
If TypeScript has the integration testing framework in place to verify that the compiler actually works (and it should) - then, presumably, you should be able to swap in a Chinese Room black-box and - at least - know that it works.

You do have to be worried that it's possibly installing trojan horses on your computer while compiling code, or any other number of unwanted side effects.

But you can and should be able to have integration testing in place to know that a compiler - at a minimum - actually works.

Totally fair. The thing is, though, agents often write code in ways I don't expect, and I don't think any human would write, which makes me think that code may also break in a way that no human expects or would have written a test for.
Your way of working is definitely going away. And quickly. The idea of reviewing code today is already a questionable use of time. In a few more months to a year it will clearly be a waste of time.
The only group of people saying this are those who didn't have much technical ability to begin with.
Found the meat proxy. Your kind will be the first to be replaced. Useless without the machine doing the actual work of thinking.
You’re a waste of time.
I use oxc tooling and it's great to see the rust rewrite singularity in action and get to ride the fastest horses, but I would like that they made a branch for 7.2 as experiment to see how it compares. Maybe this ends in a win for Microsoft, they could cut operating expenses by keeping just Anders Hejlsberg in a hammock reciting invariants to claudpilot.
I'm tired of all the new tools that comes out every day, but I would say, this is basically the Vite team and if they implement it with Vite+, then I'm all for it, less decisions about tooling to be made, one config file, etc.
Obligatory reminder that their needs from a TS compiler are extremely different from a regular web developers iteration cycle. They are trying to run millions of these while saving on costs.

You almost definitely don't need to immediately plan to switch.

> This enables new possibilities when combined with agents: You are now able to run a development toolchain end-to-end in a fully sandboxed environment on Cloudflare.

True. Looks like main use-case is AI Agent Sandboxing

Indeed I keep using Java and .NET as much as possible, with the various JIT and AOT compilation options that are available across ecosystems, no need to rewrite into either Rust or Go for Web development.
I expect I'll switch once Vite starts shipping it by default.
Ah took me a while to understand the reason behind this.

It wasn’t “let’s build a faster Rust based Typescript compiler” at all. That was a nice side-effect.

They needed a Typescript compiler that can run on their WASM only sandbox. So the only existing option was to export tsc Go to WASM, but that comes with the full Go runtime.

And to avoid that cost, they experimented with a Rust compiler and turns out it’s even faster than the reference tsc/Go implementation.

Another reason: type aware listing in oxlint.
Oxlint already has type-aware linting, integrated with TS7/typescript-go.
Yeah but now it can just all be in rust, which is a lot simpler.
> It wasn’t “let’s build a faster Rust based Typescript compiler” at all. That was a nice side-effect.

Then why are the performance graphs the headliner topic in the article? The WASM sandbox is barely a footnote.

> Then why are the performance graphs the headliner topic in the article?

If you’ve got it, flaunt it?

> The WASM sandbox is barely a footnote.

This one is a real head scratcher. The sandbox was clearly what set them on this path.

Maybe they believe the performance gains are worthy of being discussed by themselves?

What objective things can you mention about the WASM sandbox besides saying "it works"? People prefer seeing good benchmarks.
that makes sense, shinpping the whole go runtime into a WASM sandobox would have been a feavy price just to compile TypeScript
I've been playing with running Gleam's official WASM compiler on Cloudflare's sandboxes and it's pretty cool what you can do.

Built this little vibe-coding app as an experiment/cost exploration: https://glare.run

It's awesome how cheaply you can run an entire agentic coding loop (including compilation & live reload) in their v8 isolate sandbox.

Oh god, I wish this Rust fetishism would end soon.
For those who downvotes my comment, I don't give a shit. Use your brain.
Hey there, TypeScript team member here. The tsrs project has been extremely interesting to see come together. We've been working with the maintainers to better understand how tsrs is fast and what sorts of optimizations it uses are safe. We even did our own Rust vibe port and what we currently suspect is that a lot of the speed does not just come down to language choice, and some of what is going to make TS 7.1 faster and leaner (see the charts in the blog post) actually comes from optimizations discovered in tsrs.

We think the wasm and oxlint integration makes a lot of sense for Cloudflare's needs, so this investment makes sense. At the same time, we'll be working hard and collaborating to make the official TypeScript toolset faster and even more efficient.

Congrats to the tsrs team on making this official. We're excited and we look forward to continuing on collaboration!

At this point, why invest further in TSGO?

No matter how many optimizations can be ported from tsrs to ts-go, Rust will be more efficient and enable the WASM use case.

The premise of porting the compiler from TS to GO was ease of migration due to Go's garbage collector. That doesn't hold anymore? AI doesn't care how hard or easy a migration is if a test suite exists.

> That doesn't hold anymore? AI doesn't care how hard or easy a migration is if a test suite exists.

Sure, but that only matters if migration is going to be the last thing anyone does on a project. Unless you think typescript 7.1 ought to be enough for anybody, it also matters what the typescript team wants to write/read/reason in.

To be fair, as JavaScript linter, there is only so much that the team can keep coming up in terms of features, given that they learnt their lesson on not adding further extensions to JavaScript.

JavaScript isn't getting new types all the time.

I would love this to be typescript 8 and 8.1 story (:
Your answer is within the comment you wrote. AI is maintaining tsrs whereas humans are maintaining tsgo.

Your question boils down to "why would humans maintain something?" which could have a variety of answers depending on context.

The tsgo team is also using AI, see recent interviews.

Remember they are employed at CoPilot everywhere company.

No, the question is now: "How much human mental momentum, ego, and investment is there in and behind any particular project or its forks?"
I for one would be demotivated. Why maintain an official compiler that's not even half as fast as the vibe-coded one?

"Just" publish the language specs and be done.

These ports are borrowing large parts of the architecture, algorithms, and data structures from the official implementation.

I don't think a spec would facilitate them at such a low effort level and cost.

> Why maintain an official compiler that's not even half as fast as the vibe-coded one?

Because at the end of the day, someone has to actually care and put in effort, even if the thing is machine generated, because it can go off the rails.

Because its impossible to stay motivated working on non trivial project when AI is running the show. Its the last thing Id want to do, its soul sucking and the code is terrible. Remember these guys have poured years of actual work, not slop into tsgo. You sloppers wouldnt understand that.
You need the experience of building and maintaining a compiler to make a great language spec. The tsrs team specifically said they don't want to be trying to change the spec.
TSGO is already plenty fast and overkill for most projects.

Sure the Rust version is faster but the difference is probably only noticeable in the top 1% largest projects.

I'm always mind-blown when I read stuff like "speed is overkill". Speechless!
Fast is one thing, TSGO is fast enough I think, but my god does it suck up memory
tsrs also has an LSP, so will be interesting to see how much memory it consumes vs tsgo.
Because TSGO is stable and compatible?

I assume that most of the speedup in ts-rs does not simply stem from using a language without garbage collection, but actually from doing smart optimizations that can be done in any langauge.

Similar to how uv in the Python world explained that their implementation being in Rust has very little to do with the most impactful speedups they did.

If MS don't throw out tsgo right now and take this I don't think they really believe in AI prospects they're selling.
I just vibecofed tsasm. tsrs is obsolete now and anyone who still uses it is hopelessly behind the times. The tsrs team should delete the repository immediately and join my project.
I am okay if agents can write code that is very safe in ASM. I am sure code written in Rust are naturally safe compared to asm or c. Waiting for tsasm to be significantly faster and safer than tsrs.
People massively overestimate Rust's "safety" - it has a very nice approach to managing data races, and. that's it.

It still, like every other language/tool we have that shares state between threads, has race conditions, for example.

That is a confidently incorrect assertion.
You are being downvoted but you are absolutely correct. I have never seen someone assert Rust is a 100% safe. Its touted purely as a _memory_ safe language. To claim otherwise is absurd and very telling of the writer's biases
> I have never seen someone assert Rust is a 100% safe

Please copy and paste from my post where that's being asserted

> Its touted purely as a _memory_ safe language

Which is different from what was said... how?

> To claim otherwise is absurd and very telling of the writer's biases

To pretend that those claims were made is what's actually telling of biases.

> How can Codex write fast-to-compile Rust code, do tell?? Do tell!

Because memory safety isn't just about data races. In fact data races are far from Rust's most innovative or important feature. They are a side-effect, the designers had a nice system and saw it can also prevent data-races, so they said "sure, why not".

> I have never seen someone assert Rust is a 100% safe

Maybe I spend too much time on tech internet...

They said race conditions and specifically exempted data races. You can absolutely write race conditions in rust, they're a logic bug.

As an example, let's say you have two functions A and B. A only works properly if B has never ran for some reason. Let's say they both accept a reference to a value C, and B changes C's value somehow. Because this is rust, we can't have data races, so we wrap it in an ArcMutex or what have you. That doesn't impact the ordering of A and B at all.

If we spawn threads that execute A and B at the same time, it's up to the scheduler if A functions properly.

Thanks, I think that most people read "data races" and jump to "race conditions in general"

And that is my core complaint - data races are well-understood and preventable now, whether statically via Rust's borrow checker (or pure immutability in functional languages) or dynamically with tools like Go's -race detector.

Logic races remain an application-level problem regardless of language design.

Borrow checker aside, I would like to think that its type system inherently makes it safer than a language like C.
Even Modula-2 (1978) type system is safer than C.
I'm pretty sure a program written in asm by agents will not only be very unsafe, but also very slow compared to Rust, or even Go or Java.
Too late I just shipped tsvhdl so you have a hardware implementation of the actual TS compiler. Why steal valuable CPU cycles from agent workflows, off load all transpilation and type checking to a dedicated TSC chip.
Too late I just shipped tsasic so you can have a custom-made board for every single application you will ever write.
Too late, I just shipped tsqntm, who needs silicon when you can use qubits to accelerate every state of every program all at once
Egg upon all your faces! I have released tsoracle, which knows (by unknown means) whether your ts compiles correctly, instantly!
Larry Ellison's hitmen are already on your tracks for trademark infringement.
Just input the correct prime number and watch your code compile instantly
I already started manufacturing 100 shipping containers of left pad machines. Taking orders.
Did you? GitHub link? because that would be awesome! which asm target did you pick? I looked at using LLVMs' LVM because I didn't want to have to choose ARM or x86? What are some of the trade-offs you made along the way? Wait, are you making a joke and think you're funny? (Hate to be the bearer of bad news but you're not.)
I never understand why people say things like this. It is not uncommon for languages to have multiple implementations, everything must not be abandoned for Rust man.
There are precisely two languages that make the most sense to implement the TypeScript compiler in: Rust and TypeScript itself.

A Rust implementation will have the fastest compilation speeds, memory safety, can easily be compiled to WASM, or compiled to a native node module.

A TypeScript implementation provides the most convenient interface and packaging for TypeScript code that needs to use the typescript package as a library. Pure JS, no native code or WASM dependencies. No FFI tax, can be jitted.

Go was always a compromise to make a port easier for humans. Go's GC makes it easier to keep the general code structure from the TS implementation. However that GC is also a liability, you sacrifice speed and embeddability.

Personally I'd prefer they went back to TypeScript for the reference implementation, and used Rust for the performance implementation. Go doesn't bring anything to the table anymore.

> There are precisely two languages that make the most sense to implement the TypeScript compiler in: Rust and TypeScript itself.

Incorrect. I can maybe agree that those are the only perfect languages to implement tsc in them (if there is such thing). But in the real world, "perfect" does not actually mean "it's a good idea". Go made the most sense to port to (especially before agents), more than Rust (although C# could also be a good idea IMO).

C#'s embeddability/interop story is even worse than Go's; IIUC this was the primary reason they chose not to use it.
C#'s embeddability/interop story is as good or better than Golang's. The primary reason they chose not to use it was that C# was seen as too verbose compared to the TS original source. In particular TS used a lot of top level functions and bare/anonymous data types and while C# has picked up top level function support it's still not "idiomatic" and while C# has a long standing anonymous data type support it's not very "ergonomic", certainly not compared to TS structural typing. Golang's traits are a bit more ergonomic by comparison, unfortunately.

I also still think C# would have been a better long term option for maintainability, but I'm not on the Typescript team and didn't get a vote, and I can understand their methodology even if I don't agree with it.

> while C# has picked up top level function support it's still not "idiomatic"

It has no such thing. C# has top-level statements in one file per project, which omit the usual entrypoint Main boilerplate, but that's the extent of it.

Another advantage of AI, though, is that it becomes easier to maintain more than one TypeScript compiler. Perhaps there's some benefits to having some diversity?
Please you port it if its so easy, the tests are available on gh. I wont be using an llm ported ts compiler anyways, and neither would many others

Its a great way to divide and kill the popularity of your project. I made sure bun is no longer used in my devices or projects that depend on it for example, I'm not alone in this.

If an AI agent could vibe-optimise tsgo, why port it all again over to rust?
The reason Anders gave at the time was Rust effectively outlaws cyclic data structures, which was not fitting of their implementation.
As someone maintaining a close to 3M life Rust codebase, the downsides are real, especially rustc speed. I contribute to the mbx cache project but it only helps so much. It's only a small exaggeration to say that I fantasize daily about pursuing to Go.
(comment deleted)
Thanks for the input, glad to hear both parties benefit.

Could you elaborate on what type of optimizations were added to TS 7.1? As in, were they more algorithmic or related to memory management?

If I recall correctly, a few of both - there were instances where some work could be done more lazily/minimally (https://github.com/microsoft/TypeScript/pull/64476), and there were instances where we changed our allocation patterns and played around with some struct layouts. We originally strived not to drastically reorganize our data structures to make things easier to port, and we have more flexibility now. We're continuing to experiment more here.
Been with TS for many years now and the work your team's done over the years is amazing. Thank you
Ah I was gonna ask what happened with tsc-rs by Theo but looks like you guys are merging it in, at least it won't be a waste of his $500k in token spend, lol.
+1 from what I’ve seen, porting apples to apples to rust only impacts performance by a few % (sometimes in the wrong direction). The main speed up comes from algorithmic improvements that can also be applied to the original project.
It appears they're using a unique memory model (https://github.com/oxc-project/tsrs/blob/main/docs/PORTING.m...) to overcome the challenge that prevented the TypeScript team from choosing Rust to begin with: Rust has no GC and porting from a GC language to it often requires restructure of data.

Essentially, they fake a GC via never-freed arenas for long-living objects. It's interesting that Rust can do that (hopefully soundly)!

From the file:

>Create with P::new(value). p.get() returns &'static T. [...] unless an explicit recycling site proves them dead

It's unsound, the LLM/human is doing the proving. They've hidden unsafe in an abstraction without removing the unsafeness. Using the arena allocator's lifetime would have been safe and easy (bumpalo recommends this AFAIK).

I'm guessing a sycophantic LLM either found or praised this load-bearing seam.

> Never deallocating would have been sound (missile memory management: https://devblogs.microsoft.com/oldnewthing/20180228-00/?p=98... ).

Calling this a breakthrough in memory management is an understatement. Call up the Turing Award committee. We just discovered a solution to the halting problem! Turns out that for certain applications the answer is unequivocally "yes"

We've have found an engineering solution to some of the cases for the halting problem, yes. It's still not solved science problem though. Science isn't engineering though.
Wouldn't that eat the whole ram?
Compilers often just build up more and more data structures in memory until the end when they then release everything more or less at once. With an arena you can then just throw away the whole arena at the end, assuming there are no resource handles that need to be closed in drop().

A long time ago I read an article about someone speeding up a C++ compiler that is itself written in C++ (was it g++? maybe clang?). They simply patched out delete so it did nothing. The compiler used marginally more memory but ran much faster, since releasing all the small objects one by one is just useless work at the end of the compilation.

A GCed language has a similar behavior and could therefore be fast in that case. It just builds up all the objects and then when the program exists it doesn't have to GC them all, it just throws away the whole process memory. So I can imagine one could "optimize" a compiler written in a GCed language by deactivating the GC.

I read on here a few months ago about some high-frequency trading system being written in Java and running with no garbage collector enabled, because the application is closed at the end of trading each day and it's extremely fast without garbage collection.
This is what bothers me about all the vibe-coded Rust ports. The LLMs are mostly porting the existing architecture and code as-is, which was intended for a different language with different features and tradeoffs. A port that actually uses Rust’s features and is architected in a way that makes sense for Rust code would be a lot better, more maintainable (if that matters anymore) and probably faster too.

Another advantage human ports have is the opportunity to reconsider earlier architectural decisions and change them, instead of just enshrining them in the new language.

I never see this caveat mentioned in all the "... vibe-ported to Rust" threads, which makes me wonder who comments on these projects. I hand-ported a few TS hobby projects to Rust+WASM pre-AI and realized there are only two ways to go: Do a low effort translation and create very unidiomatic Rust code or redesign the application from the ground up. There's no middle ground. Option 1 is almost a waste of time and option 2 is incredibly difficult.
option 2 is also impractical for most part. doing a rewrite is big thing already, changing implementation paradigm would make "catching up" impossible.

Only practical option is to do low level rewrite (otpion 1) and then rewrite module by module into better approaches.

Shameless plug of my Typescript C# port. It's a case study with some interesting (perhaps) notes from me in the README about approach, performance, and cost(~$75).

https://github.com/stepwisehq/typescript-dotnet

I'm going to do a taboo and comment on my own comment.

I didn't push performance in a way that would cause big deviations from the Golang project's algorithms and data structures; similar to how the TS team didn't want to deviate too far from the JavaScript source till now. Aggressive unmanaged arenas and object pooling was the direction I would have pursued..

The GC in DotNet is a source of major frustration for a tool like this. Without tuning lots of gen 0/1 work occurs to determine if objects should be promoted. The tuning is still not an ideal solution IMHO. Fully unmanaged arenas and aggressive object pooling could help here, but an alternative GC may be part of an ideal, comprehensive solution.. I have have a play with ZeroGC.

There is a warning on the repo that it's not maintained, but I've been curious about the process of updating it to sync "upstream" changes. And it sounds like the TypeScript team are going to start incorporating some of the performance techniques identified in the Rust port in the 7.1 release so... I'll probably at least sync it to up to 7.1 and keep it as an active experiment and case study on LLM porting and DotNet AOT performance.

It's just good fun.

It sounds like the big 7.1 performance trick will be unmanaged arenas, so yeah maybe something your LLM agent picks up for "cheap".
Yeah, that definitely seems like the case.

The benefit of those enhancements being wrapped into the reference implementation is it's "easier" for humans and LLMs to reconcile and keep things in sync.

I benchmarked tsrs a few weeks ago. I was testing out tsgo, ts-rust, tsrs, and bun for typechecking on our monorepo. tsrs is definitely awesome, it is very memory efficient when bumping up the number of threads. Not as efficient as bun, but it has incremental checks, which bun does not have.
so rust is now go-to slop language? can't you guys use C or something. I want rust back.
What? You realize how many people now are excited about Rust that were not before? I am, for one.
So excited that you avoid writing a single line of it at all costs.
Well, it's either typed and memory managed Rust or underperforming NextJS/Python slop. Also, I've read way more Rust and understand the general idea than I ever did before AI tools became good enough. Using a neat package called Crux for cross platform apps which uses the Elm architecture, which I've very familiar with and have written in the past.
There are so many more amazing options between Rust and JS/python.
Rust is basically the perfect language for LLMs because it has a strong, comprehensive, and strict compiler. For coding you really need a tight loop for models so they can iterate. C doesn’t accomplish this because it’s far too “anything goes” so bugs slip through. Dynamically typed languages don’t work either because their source code doesn’t contain enough context.
I wonder how fast "Doom in TypeScript" runs in tsrs now. XD
How long until Crysis in typescript?
(comment deleted)
What strange times. A few years ago seeing a headline like this, my jaw would have literally dropped. Instead I'm wondering what kind of software projects will have meaning in the future if this headline feels common.
this is insane! saw a quote tweet of this by an infra engineer at chat gpt who said “ I'm looking at migrating over for the ChatGPT codebase and saw ~70% improvements on both wall time perf + peak cpu/memory usage.

this is great for getting work done faster but also much better if you want to run concurrent agents/worktrees at scale”. https://x.com/feedthejim/status/2112584843368570921?s=46

then i went and tried this on my own open source harness. type checking went from 10 seconds to under half a second and uses a quarter of the memory. madness

I guess it will be soon that typescript won’t matter anymore since agents will be writing code is Rust compiled to WASM or similar for everything. typescript added human readability or JavaScript, if no human is coding, I don’t see the point of wasting tokens on this.
> typescript added human readability

Ehm no, added type safety, and dealing with a type checker it's exactly what agents need.

> if no human is coding

Nope outside the bubble there are many still hand coding(me too)

> I guess it will be soon that typescript won’t matter anymore since agents will be writing code is Rust

Oh hold on a second isn't Rust the same as Typescript "adding human readability"?! Why not trashing Rust and just have LLMs output WASM directly? XD Wasm which is basically useless outside the browser or some microvms on the edge, and in the browser you don't even have an interface for directly rendering anything and still have to deal with the dom

You either are highly non technical, very junior or I just don't know

Which language do you write to run code in browsers, especially that can manipulate DOM?

You need a quick reality check.