884: Typescript Just Got 10x Faster
Digest
This podcast details the significant performance improvements achieved by porting the TypeScript compiler and toolset to native code using Go. The 10x speed increase impacts the entire compilation pipeline, from parsing and type checking to code emission, benefiting both command-line users and IDE integrations like VS Code. The improved speed enables faster loading times, near-instantaneous type checking, and opens doors for advanced AI-assisted code analysis. The team discusses the challenges of porting versus rewriting, the choice of Go over other languages like Rust (due to its garbage collection, concurrency support, and suitability for TypeScript's functional style), and the porting methodology (initially manual, then automated). They address concerns about induced demand and the potential for increased type complexity, highlighting the importance of responsible type system usage. The podcast also explains the use of shared memory concurrency for parallelization, particularly in embarrassingly parallel tasks like parsing. Finally, the team outlines future plans, including a complete command-line compiler replacement, a new Language Server Protocol (LSP)-based language server, and further AI integration. The timeline for release is discussed, with a command-line compiler replacement targeted for the end of spring and a full language server by the end of the year.
Outlines

TypeScript Compiler's 10x Performance Boost and Native Code Port
The TypeScript compiler and toolset have been ported to native code, resulting in a 10x performance improvement across all compilation phases. This significantly speeds up the entire compilation process.

Impact on Editor Integration and Language Services
The performance improvements extend to editor integrations like VS Code, leading to faster loading times and near-instantaneous type checking. This also opens opportunities for advanced features like on-the-fly AI-assisted code analysis.

Addressing Induced Demand and Type System Considerations
The podcast discusses the potential for increased type complexity due to the speed improvement and the need for responsible use of the powerful type system to avoid performance regressions. Concerns about the Turing-completeness of the type system and potential infinite loops are addressed.

Development Process and Go's Role
The development process is detailed, including the challenges of porting versus rewriting and the reasons for choosing Go (native executable support, garbage collection, concurrency). The suitability of Go for TypeScript's functional style is highlighted.

TypeScript Codebase Structure and Porting Methodology
The discussion focuses on the TypeScript codebase's functional style and its alignment with Go. The porting process, initially manual then automated, and challenges in adapting the JavaScript object model to Go are explained.

Parallelization Strategies and Concurrency
The podcast explains how shared memory concurrency is leveraged for significant speed improvements, especially in embarrassingly parallel tasks like parsing. The limitations of JavaScript's concurrency model are contrasted with Go's capabilities.

Addressing Slow Parts of TypeScript and Future Optimizations
Specific slow parts of TypeScript, particularly the type checker, are addressed, along with optimization strategies like isolated declarations and "no-check" mode.

Large Codebases, Future Plans, and Timeline
The episode explores performance challenges in large TypeScript codebases and how the new compiler addresses them. Future plans, including increased AI integration and improved tooling, and the release timeline are discussed.
Keywords
TypeScript Compiler
The program that translates TypeScript code into JavaScript; significantly improved performance due to a native code port.
Native Code Compilation
Compiling directly to machine code for faster execution.
Go Programming Language
The language used for the TypeScript compiler port, chosen for its native executable support, concurrency, and garbage collection.
Shared Memory Concurrency
A programming model enabling efficient parallel processing, crucial for speed improvements.
Type Checker
The part of the compiler verifying type correctness; a major performance bottleneck previously improved significantly.
AI-assisted Code Analysis
Using AI to enhance code analysis, enabled by speed improvements.
Induced Demand
Increased usage due to infrastructure improvements, potentially negating benefits.
Language Server Protocol (LSP)
Go's native executable support, garbage collection, concurrency features, and alignment with TypeScript's functional style.
Q&A
What is the primary benefit of porting the TypeScript compiler to native code?
A 10x performance improvement across all compilation phases, reducing build times.
Why was Go chosen for the port?
How does shared memory concurrency contribute to performance gains?
Allows multiple threads to work simultaneously on different parts of the compilation process.
What are the future plans for the TypeScript compiler and language service?
A complete command-line compiler replacement, a new LSP-based language server, and increased AI integration.
What are some challenges in achieving a 10x performance improvement?
Optimizing the inherently complex type checking phase.
When will the new compiler be available?
A command-line compiler replacement is targeted for the end of spring, a full language server by year's end.
Show Notes
Wes and Scott talk with Anders Hejlsberg and Daniel Rosenwasser about TypeScript’s leap to native code. They discuss the challenges, trade-offs, and the decision to port TypeScript to Go, unlocking faster compilation, better concurrency, and new possibilities for AI-assisted development.
Show Notes- 00:00 ">00:00 Welcome to Syntax!
- 00:38 ">00:38 TypeScript compiler goes native
- 05:24 ">05:24 Challenges in rebuilding TypeScript
- 08:49 ">08:49 How long has this been in development?
- 10:32 ">10:32 What does porting TypeScript to native entail?
- 16:36 ">16:36 Why choose Go?
- 26:48 ">26:48 The porting process
- 35:02 ">35:02 Brought to you by Sentry.io
- 35:27 ">35:27 Type checking and parallel compilation
- 42:36 ">42:36 Fixing TypeScript’s performance bottlenecks
- 49:09 ">49:09 Large TypeScript codebases
- 54:11 ">54:11 What’s the timeline for the new compiler?
- 58:39 ">58:39 Optimization and AI
- 01:00:32 ">01:00:32 New features?
- 01:04:15 ">01:04:15 Sick Picks + Shameless Plugs
- Daniel: pprof-it
- Anders: USB Hand Warmers
Syntax: X Instagram Tiktok LinkedIn Threads
Wes: X Instagram Tiktok LinkedIn Threads
























