How to Achieve 10x Faster TypeScript Compilation

TL;DR
TypeScript is being ported to native code using Go, resulting in a compiler that is over 10 times faster. This shift addresses performance and memory issues inherent in JavaScript, allowing for faster project loads and batch compiles. The port maintains the same semantics as the original compiler, ensuring consistent behavior.
Transcript
Hi everyone uh this is Anders Hejlsberg lead architect of the typescript project and Technical fellow at Microsoft um today I'm here to talk about project Corsa which is our effort to Port uh the typescript compiler and tool set to native code now since uh the inception of typescript more than a decade ago uh typescripts been written in itself ... Read More
Key Insights
- TypeScript is being ported to native code using Go to improve performance.
- The JavaScript runtime is optimized for UI, not compute-intensive tasks like compilers.
- The new compiler is over 10 times faster, significantly improving project load times.
- Porting involves translating existing TypeScript code to Go, maintaining semantics.
- Concurrency and native code execution are key factors in the performance gain.
- The ported compiler supports cyclic data structures and concurrency in Go.
- The new language service uses the Language Server Protocol (LSP) architecture.
- Future goals include supporting JS, JSX, and exploring AI-assisted capabilities.
Install to Summarize YouTube Videos and Get Transcripts
Explore YouTube Video Summarizer or Get YouTube Transcript Extractor
Questions & Answers
Q: How is TypeScript's performance being improved?
TypeScript's performance is being improved by porting its compiler and toolset to native code using the Go programming language. This transition addresses the performance and memory limitations of JavaScript, resulting in a compiler that is over 10 times faster. The move to native code allows for better concurrency and control over data layout, significantly enhancing project load times and batch compile speeds.
Q: Why was Go chosen for porting TypeScript?
Go was chosen for porting TypeScript because it offers the most suitable features for the workload involved. It provides optimized native code support across all platforms, great control over data layout, automatic memory management with a garbage collector, and excellent concurrency capabilities. These features make Go the ideal choice for achieving the desired performance improvements in the TypeScript compiler.
Q: What are the key benefits of the new TypeScript compiler?
The new TypeScript compiler offers several key benefits, including a more than 10 times increase in speed, which significantly improves project load times and batch compile speeds. It maintains the same semantics as the original compiler while providing better concurrency and control over data layout. Additionally, the new compiler supports cyclic data structures and leverages the Language Server Protocol (LSP) for modern language service features.
Q: How does concurrency contribute to the performance gain?
Concurrency contributes to the performance gain by allowing multiple processes to run simultaneously, effectively utilizing available CPU cores. In the new TypeScript compiler, tasks like parsing and binding are fully concurrent, meaning they can be executed in parallel across multiple files. This approach drastically reduces compile times and enhances overall performance, especially in compute-intensive workloads.
Q: Will the new compiler support JavaScript and JSX?
Yes, the new TypeScript compiler is expected to support JavaScript and JSX in the future. While the current port does not yet include these features, they are part of the development roadmap. The goal is to have a fully functional replacement command line compiler that supports JS, JSX, project references, and potentially incremental compile by the end of the year.
Q: What is the Language Server Protocol (LSP)?
The Language Server Protocol (LSP) is a standardized protocol used by language servers to communicate with development tools, such as IDEs. It allows for consistent language features like autocompletion, go-to-definition, and error checking across different editors. The new TypeScript language service adopts LSP, enabling more modern features and AI-assisted capabilities, and providing a more seamless developer experience.
Q: How does the port maintain the same semantics as the original compiler?
The port maintains the same semantics as the original compiler by translating existing TypeScript code to Go while preserving all implicit behaviors and decision-making processes. This means that the ported compiler retains the same logic and functionality, ensuring that all types and inference candidates are handled consistently, resulting in identical behavior between the old and new compilers.
Q: What future developments are planned for the TypeScript compiler?
Future developments for the TypeScript compiler include supporting JavaScript and JSX, introducing new interprocess APIs for communication with other languages, and exploring AI-assisted capabilities for enhanced refactoring and code analysis. The team aims to release a fully functional replacement command line compiler within the year, leveraging the 10x performance gain to enable new kinds of AI features and improve the overall developer experience.
Summary & Key Takeaways
-
TypeScript is transitioning to a native code base using Go, resulting in a compiler that is more than 10 times faster. This change addresses performance and memory limitations of JavaScript, providing faster project loads and batch compiles while maintaining the same semantics as the original compiler.
-
The porting process involves translating existing TypeScript code to Go, ensuring that all implicit behaviors and semantics are preserved. Concurrency and native code execution are major contributors to the performance improvement, with the new compiler supporting cyclic data structures and offering better control over data layout.
-
The new language service adopts the Language Server Protocol (LSP) architecture, allowing for more modern features and AI-assisted capabilities. Future developments aim to support JS, JSX, and new interprocess APIs, with a fully functional replacement compiler expected within the year.
Read in Other Languages (beta)
Share This Summary 📚
Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator
Explore More Summaries from Microsoft Developer 📚
![How to Find Files in the terminal with Bash [7 of 20] | Bash for Beginners thumbnail](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDzo38btP-Bc%2Fhqdefault.jpg&w=750&q=75)

![What are Environment variables? [10 of 20] | Bash for Beginners thumbnail](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FaKghi0hI1OA%2Fhqdefault.jpg&w=750&q=75)


![Exploring and comparing different LLMs [Pt 2] | Generative AI for Beginners thumbnail](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKIRUeDKscfI%2Fhqdefault.jpg&w=750&q=75)
Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator