Skip to main content

Command Palette

Search for a command to run...

Microsoft Rewrites TypeScript in Go for 10x Faster Performance

Project Corsa: Microsoft's strategy for a 10x faster TypeScript via Go.

Published
4 min read
Microsoft Rewrites TypeScript in Go for 10x Faster Performance

Microsoft's TypeScript Transformed: A Leap to Go Achieves 10x Performance Gains

Introduction

Microsoft is embarking on a transformative journey for TypeScript, revamping its core infrastructure to address long-standing performance bottlenecks. By porting the TypeScript compiler from TypeScript/JavaScript to Go, a statically compiled language, Microsoft aims to deliver unprecedented speed and efficiency gains for developers. This initiative, known as Project Corsa, promises to accelerate build times, reduce memory usage, and enhance the overall development experience.

The Challenge: TypeScript's Performance Bottleneck

TypeScript, a superset of JavaScript, adds static typing to enhance code maintainability and scalability, especially in large projects. However, the existing TypeScript compiler, tsc, written in TypeScript and running on Node.js, has faced performance challenges, particularly in large codebases. These challenges include:

  • Slow Compilation Times: Large projects often experience significant delays during compilation, impacting developer productivity.

  • High Memory Usage: Running the compiler on a JavaScript runtime consumes substantial memory, straining system resources.

  • Editor Latency: Sluggish performance affects real-time features in IDEs, such as code completion, error checking, and refactoring.

The Solution: Project Corsa and the Go Port

To overcome these limitations, Microsoft initiated Project Corsa, a strategic move to port the TypeScript compiler to Go. Go, renowned for its performance, concurrency, and efficient memory management, offers a compelling alternative to the JavaScript-based implementation.

Why Go?

The decision to use Go was driven by several key factors:

  • Performance: Go's ability to compile directly to machine code eliminates the overhead of running on a JavaScript runtime, resulting in substantial speed improvements.

  • Concurrency: Go's built-in concurrency features enable parallel processing of TypeScript files, significantly reducing build times.

  • Memory Efficiency: Go's efficient memory management minimizes resource consumption, making it ideal for large projects.

  • Ecosystem: Go has a thriving ecosystem with excellent tooling and support, making it a practical choice for a project of this scale.

Expected Performance Gains

Early benchmarks of Project Corsa demonstrate impressive performance improvements. According to Microsoft's internal tests, the Go-based TypeScript compiler achieves a 10x speedup compared to the current implementation. The table below illustrates the performance gains observed in various popular codebases:

CodebaseSize (LOC)Current (s)Native (s)Speedup
VS Code1,505,00077.87.510.4x
Playwright356,00011.11.110.1x
TypeORM270,00017.51.313.5x
date-fns104,0006.50.79.5x
tRPC (server + client)18,0005.50.69.1x
rxjs (observable)2,1001.10.111.0x

These results indicate that Project Corsa has the potential to significantly accelerate TypeScript development, enabling faster builds and more responsive IDE experiences.

Roadmap and Versioning

Microsoft has outlined a clear roadmap for the transition to the Go-based TypeScript compiler:

  • TypeScript 5.8 & 5.9: Continue development on the JavaScript-based compiler, introducing new features and improvements.

  • TypeScript 6.0: Introduce deprecations and breaking changes to prepare for the native transition.

  • TypeScript 7.0: Release the Go-based native compiler as the default TypeScript implementation.

The naming convention will differentiate between the JavaScript-based (TypeScript 6) and native (TypeScript 7) versions. The codenames "Strada" and "Corsa" will be used to refer to the original TypeScript and the native port effort, respectively.

Impact on the Developer Experience

The transition to the Go-based TypeScript compiler is expected to have a profound impact on the developer experience:

  • Faster Builds: Reduced compilation times will accelerate the development cycle, enabling developers to iterate more quickly.

  • Improved IDE Performance: Faster type checking and code analysis will enhance the responsiveness of IDE features, such as code completion and error highlighting.

  • Enhanced Tooling: The new compiler will enable more advanced tooling capabilities, such as faster refactoring and deeper code insights.

  • AI-Powered Development: The performance gains will pave the way for AI-powered tools that can learn, adapt, and improve the coding experience.

Community Reaction and the Choice of Go

The decision to use Go has sparked considerable discussion within the developer community. While some have questioned the choice of Go over languages like Rust, Microsoft has emphasized that Go's performance, concurrency, and memory efficiency make it the most suitable option for porting the existing TypeScript codebase.

Conclusion

Project Corsa represents a significant investment by Microsoft to enhance the performance and scalability of TypeScript. By porting the TypeScript compiler to Go, Microsoft aims to deliver a 10x performance boost, reduce memory usage, and improve the overall developer experience. As TypeScript continues to evolve, this strategic move will ensure that it remains a leading language for building large-scale, maintainable applications.