But Why Did Microsoft Port TypeScript to Go Instead of Rust?

“If you're coming from JavaScript, you're going to find a transition to Go a lot simpler than the transition to Rust.”

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. 

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. 

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. 

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. 

📣 Want to advertise in AIM? Book here

Picture of Supreeth Koundinya

Supreeth Koundinya

Supreeth is an engineering graduate who is curious about the world of artificial intelligence and loves to write stories on how it is solving problems and shaping the future of humanity.
Related Posts
Association of Data Scientists
GenAI Corporate Training Programs
Our Upcoming Conference
India's Biggest Conference on AI Startups
April 25, 2025 | 📍 Hotel Radisson Blu, Bengaluru
Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.