Why Microsoft Switched to Go for the TypeScript Compiler – 10× Faster
Microsoft rewrote the TypeScript compiler in Go, achieving a nine‑to‑tenfold speed boost, and explains that Go’s low‑level design, built‑in garbage collection, cross‑platform compilation, and functional‑style compatibility made it a better fit than C#, reflecting both technical advantages and Microsoft’s internal “Eat Dog Food” culture.
Background
Microsoft recently rewrote the TypeScript compiler in Go and published benchmark results that show a roughly nine‑to‑ten‑fold performance improvement over the previous implementation written in C#.
Benchmark
The published chart indicates that most test cases achieve a 9–10× speed increase when compiling TypeScript source files.
Why Go instead of C#?
Low‑level performance and cross‑platform model – Go compiles to native machine code and includes a built‑in garbage collector. It produces a single binary that runs on Windows, macOS and Linux without requiring the .NET Core runtime. C# is an IL‑based language that depends on the .NET runtime, adding startup overhead and complicating cross‑platform builds.
Design heritage from Plan 9 – Go inherits Plan 9’s emphasis on a simple, fast cross‑platform compiler and channel‑based concurrency, which contribute to its efficiency.
Fit with TypeScript’s functional style – TypeScript’s core is heavily functional and avoids deep class hierarchies. Go’s struct and interface system aligns with this model, reducing the friction that would arise from forcing an object‑oriented paradigm in C#.
Internal development practice – Microsoft’s “eat‑your‑dog‑food” culture encourages using tools that prove effective in production, allowing rapid feedback and iteration on the compiler.
Broader context of Go at Microsoft and elsewhere
Go is already used extensively at Google to speed up C++ compilation, and it underpins many cloud‑native projects such as Docker and Kubernetes. Its proven performance‑critical track record makes it a sensible choice for a high‑throughput compiler like the TypeScript transpiler.
Conclusion
The combination of Go’s low‑level efficiency, built‑in garbage collection, simple cross‑platform deployment, and its compatibility with TypeScript’s functional design explains the decision to rewrite the compiler in Go, resulting in a substantial 9–10× speedup.
Code example
来源丨经授权转自公众号明月三千
作者丨
明月三千Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
