Jake Bailey from the TypeScript team at Microsoft details how they ported the TypeScript compiler from TypeScript/JavaScript to Go, achieving over 10x performance improvements. Key motivations included JavaScript's single-threaded limitations, memory constraints in Electron, and inability to share objects between threads. The port required preserving exact behavior (no spec exists, only a canonical implementation), so a semi-automated tool called 'ts-to-go' was built to assist the translation. Major technical decisions covered include a custom AST node layout using embedded structs instead of interfaces to avoid nil-in-interface bugs, arena-based allocation pools for a 20% parse speedup, UTF-8 string handling replacing UTF-16, and concurrent parsing/binding/emit phases. Type checking concurrency was solved by spawning multiple independent checkers per file subset. The team also migrated from a custom synchronous language server protocol to LSP. Real-world results: VS Code's 1.5M-line codebase went from ~80s to ~7s compile time; Slack's build dropped from ~6 minutes to ~40 seconds. TypeScript 7.0 is planned as the Go-powered release.
•39m watch time
6 Impressions1 Comment