0 85

Microsoft ports TypeScript compiler to GO

Categories: Microsoft Technologies
Microsoft ports TypeScript compiler to GO

​Microsoft has embarked on an initiative to enhance the performance of the TypeScript compiler by porting it from its current TypeScript implementation to Go. This transition addresses performance challenges, particularly in large codebases, by offering a native compiler and tool set. 

Performance Improvements:

The native Go implementation is expected to deliver substantial performance enhancements:

  • Significantly faster load times for large projects.​
  • Reductions in build times by 10x.
  • Notable decreases in memory consumption.​

For instance, compiling the Visual Studio Code codebase (approximately 1.5 million lines) currently takes about 77.8 seconds. With the Go-based compiler, this time is reduced to 7.5 seconds, marking a 10.4x speed improvement. ​

CodebaseSize (LOC)CurrentNativeSpeedup
VS Code1,505,00077.8s7.5s10.4x
Playwright356,00011.1s1.1s10.1x
TypeORM270,00017.5s1.3s13.5x
date-fns104,0006.5s0.7s9.5x
tRPC (server + client)18,0005.5s0.6s9.1x
rxjs (observable)2,1001.1s0.1s11.0x

The rationale for Choosing to Go:

The decision to use Go over other languages, such as Rust or C#, was influenced by several factors:​

  • Garbage Collection: TypeScript's existing codebase relies heavily on garbage collection, a feature inherent to JavaScript and Go. Rust, lacking built-in garbage collection, would have necessitated additional complexity.
  • Coding Paradigms: The functional programming style prevalent in TypeScript aligns more closely with Go's design than with C#'s object-oriented approach.
  • Concurrency and Performance: Go offers robust support for concurrency and efficient native code generation, contributing to the anticipated performance gains. ​

More you can read in FAQ.

Project Timeline and Future:

The project, codename "Corsa" is progressing with the following milestones:

  • Mid-2025: A preview of the native compiler (tsc) with command-line type-checking capabilities.​
  • End of 2025: A feature-complete solution encompassing project builds and a language service.​

During this transition, the existing TypeScript compiler will continue development into the 6.x series, with TypeScript 6.0 introducing some deprecations and breaking changes to align with the upcoming native codebase. Once the native codebase reaches sufficient parity, it will be released as TypeScript 7.0. 

This strategic move underscores Microsoft's commitment to enhancing developer productivity and addressing performance bottlenecks in large-scale TypeScript applications.​

For a more in-depth understanding, you might find the following video informative:

Comments:

Please log in to be able add comments.