Microsoft is all set to port the TypeScript compiler and toolset to Go, achieving 10x faster compile speed across different codebases. Though developers largely praised the announcement, some expressed disappointment because Microsoft chose Go instead of Rust to port the TypeScript compiler.
A user on X summed up the overall sentiment perfectly. “More shocking than TypeScript getting 10x speedup is they didn’t write it in Rust,” he said.
“In a blink of an eye, Java vs C# debates have turned into Rust vs Go debates. Special thanks to TypeScript for making this happen,” another said.
Microsoft is rewritting TypeScript compiler in… Go.
byu/rodrigocfd inrustjerk
As the displeasure poured in, Ryan Cavanaugh, a lead developer of TypeScript, clarified the stance, admitting that they had anticipated a debate over this. He said that while Rust was considered an option, the ‘key constraint’ was portability, which ensured that the new codebase was algorithmically similar to the current one.
He also revealed that multiple ways were explored to represent the code so that rewriting it in Rust would be manageable. But they ran into ‘unacceptable’ trade-offs with performance, and ergonomics. Some approaches required implementing their own garbage collector (GC) and adding additional complexity.
This was in contrast with Go, where it automatically recycled memory, or what is called ‘garbage collection’. “Some of them came close, but often required dropping into lots of unsafe code, and there just didn’t seem to be many combinations of primitives in Rust that allow for an ergonomic port of JavaScript code,” said Cavanaugh.
He explained that the team ended up with two options. One was to do a rewrite from scratch using Rust, which he said could take ‘years’ and still yield an incompatible version of TypeScript ‘no one could use’. Second, build a usable port in Go within a year, which is ‘extremely’ compatible in terms of semantics, while offering competitive performance.
Cavanugh also indicated that Go, like Rust, has excellent code generation, data representation capabilities, and ‘excellent’ concurrency primitives.
He also noted that Rust excels at achieving its design goals, but being “straightforward to port to Rust from this particular JavaScript codebase” is, quite reasonably, not among them.
The same applies to Go, he explained, but given the way they had written the code so far, it turned out to be a surprisingly good fit for the task.
“We also have an unusually large amount of graph processing, specifically traversing trees in both upward and downward walks involving polymorphic nodes. Go does an excellent job of making this ergonomic, especially in the context of needing to resemble the JavaScript version of the code,” he added in a post on GitHub.
‘Transition to Go is a Lot Simpler than Transition to Rust’
In an interview, Anders Hejlsberg, the lead architect of TypeScript, largely reiterated Cavanaugh’s remarks.
He said the only way the project would be meaningful is porting the existing codebase as is. The original codebase was designed with certain assumptions – and the most important one was the presence of automatic garbage collection.
“I think [that] pretty much limited our choices, and started to heavily rule out Rust,” said Hejlsberg, indicating the lack of automatic memory management.
Still wild how similar the code is between the original TypeScript and the Go port 🤯 (vid just went live btw) pic.twitter.com/7xiJ2i2qoK
— Theo – t3.gg (@theo) March 11, 2025
Another challenge with Rust, as pointed out by Hejlsberg, is its strict limitations around cyclic data structures which the TypeScript compiler heavily relies on. The system includes abstract syntax trees (ASTs) with parent and child references, symbols and declarations that reference each other, and recursive types that naturally form cycles.
“Trying to unravel all of that would make the job of moving to native [code] insurmountably larger,” he said. Hejlsberg also explained that when they considered all their needs, Go stood out as the best fit.
It is important to note that TypeScript is built on top of JavaScript. “If you’re coming from JavaScript, you’re going to find a transition to Go a lot simpler than the transition to Rust,” said Hejlsberg.
He also said that the transition is super gentle on the system, and isn’t a “super complicated” language with an awful lot of ceremony. “Which I would say Rust comes a lot closer to,” he added.