Syntax Video
A New NATIVE Compiler for Typescript
Transcript
typescript just got a whole lot faster and in this video we're going to be reviewing the news of typescript 7 which is a fully native Port of the typescript compiler from Microsoft that promises to be 10 times faster than the current compiler so let's dive [Music] in so from the Microsoft blog is the announcement here today I'm excited to announce the next steps we're taking to radically improve typescript performance the core value proposition of typescript is an excellent developer experience as your codebase grow the value of these features also grows but in many cases typescript today is not able to scale up to the very largest code bases teams working in large projects report long load and check times and have to choose between reasonable editor startup time or getting a complete view of their Source what we hear most often from developers is that they love it when they can rename variables with confidence find all references to a particular function easily navigate their codebase and do all of those things without delay this is why we use typescript this is of course what we want and if it's faster that sounds good
to me new experience is powered by AI benefit from large Windows of semantic information that need to be available with tighter latency constraints this is one of my biggest complaints with AI coding tools like GitHub co-pilot or even cursor editor a lot of times it provides suggestions that aren't even correct in terms of typescript so if the typescript compiler was faster and the output of the typescript compiler could be provided as context for these AI tools results will be much more accurate and these AI tools will be able to Leverage The typescript compiler output and so for me that would be huge cuz it's one of my my biggest complaints of about using AI coding tools we also want fast command line builds to validate that your entire code base is in good shape to meet these goals we've begun to work on Native implementation of the typescript compiler and tools there it is so they are porting the current typescript compiler which is written with typescript to a native language which they'll talk about next the native implementation will drastically improve editor startup and reduce overall build Time by up to 10x as well as substantially reduceed memory usage this
is one of the things you may not realize but the typescript compiler is used in a lot of different places right it's used whenever you start up visual studio code to parse your whole project it's used when you run a build it runs on CI servers it's used for autocomplete and intellisense it's running in the background all the time so if the typescript compiler is this much faster you're going to see that Improvement all over the place by porting the current codebase we expect to be able to preview a TSC capable of command line typechecking by mid 2025 so just a few months away with a feature complete native based Solution by the end of the year you can build and run the go code from our new working repo which is offered under the same license as the existing typescript codebase there it is so one of the things to note here is that this is a port of the typescript compiler in the most recent episode of the syntax podcast Scott and West chatted with Andrew halber the creator of typescript and also Daniel Rosen waser who is the principal product manager of typescript and they talked about how they tried a bunch of different programming languages and ultimately settled on go so if you're curious about why they chose go
definitely check out that episode because they dive deep into architecture decisions and why go was the best choice for them and the other thing to note here is this is a port right it would be really bad if you swapped out the typescript compiler and then all of a sudden it's producing different errors so it was really important for the typescript team to create a port that was a one to one match for the current typescript compiler so for most people you're not even going to realize that there's a native typescript compiler running behind the scenes everything else will just behave the same the way it does now but it'll be faster check the readme for instructions on how to build and run TSC and the language server and to see a summary of what's implemented so far we'll be posting regular updates as new functionality becomes available for testing so this was just released but you better believe that I'm going to be diving into this native compiler I'm going to run it against a bunch of different large typescript code bases so if you have any suggestions for typescript code bases you want to see it run against let me know down in the comments all right how much faster our native implementation is already capable of loading many popular typescript repos including typescript
itself here are times run TSC on popular GitHub repos of varying sizes this is another important thing that the typescript team is keeping uh in mind is they don't want to release a compiler that just breaks a bunch of code bases so they actually filtered through all of the top code bases on GitHub open source code bases that use typescript and they're actually running this native Port against it to make sure that it still works and they can Benchmark the performance so the vs code codebase has 1.5 million lines of typescript and the current typescript compiler takes 77.8 seconds to compile it and the native version only takes 7.5 seconds which is a a 10.4x speed up the playright code base has 350,000 lines of code they saw a 10.1 X speed up the type O RM code base has 270,000 lines of code they saw a 13.5 times speed up the date functions library has 104,000 lines they saw a 9.5x speed up they also ran it on the trpc code base which has 18,000 lines of code and it saw a 9.1 X speed up and also they ran it on the rxjs code base
which has about 2,000 lines of code and they saw an 11x speed up so you can see overall on average a 10x speed up while we're not featured complete here yet these numbers are representative of the order of magnitude performance Improvement you'll see checking most code bases if you want to hear Anders hallsberg dive deeper into like what this actually means check out the podcast episode because he talks about how early on they were testing these things out and early on even without full support they could see this 10x speed up and as they added more and more feature support to this native compiler they saw the speed up remain about the same and so they're expecting as they make this native compiler more feature complete you will see on average 10 next speed up we're incredibly excited about the opportunities that this massive speed boost creates features that once seemed Out Of Reach are now within grasp types scoup can provide instant comprehensive error listings across an entire project support more advanced refactorings and enable deeper insights that were previously too expensive to compute I cannot count the number of times I am running a large like even a mediumsized typescript project and all of a sudden like my editor freezes even
on a a modern MacBook Pro with like 16 gigs of RAM I still have weights between seeing like the inference of types and stuff like that so this is something I cannot wait to try out this new Foundation goes beyond today's developer experience and will enable the next generation of AI tools to enhance development powering new tools that will learn adapt and improve the coding experience this is kind of what I talked about earlier as well once AI tools start incorporating the output of the typescript compiler you're going to see much better completions from things like GitHub co-pilot or cursor editor all right editor speed performance is often most apparent when working in an editor we've heard frequent feedback that developers want their editors load large projects faster and be more responsive modern editors like visual studio and visual studio code have excellent performance as long as the underlying language Services provide fast responses and so this is kind of the point that I got at earlier is a native typescript compiler enables things all over the place right it's not just your build time it's also inside of your editor when you're loading a project with our native implementation we'll be able to provide incredibly fast editor
experiences again using the visual studio code codebase as a benchmark this is actually really funny to think about super meta because you're opening Visual Studio code codebase in of Visual Studio code the current time to load the entire project in the editor on a fast computer is about 9.6 seconds this drops to about 1.2 seconds with the native language service an 8X Improvement in Project load time and editor scenarios now I don't know about you but I have never worked in a code base with 1.5 million lines of code but to imagine that even a codebase of that size can load this fast that's awesome to hear we expect all projects to see this level of improvement in load time overall memory usage also appears to be roughly half of the current implementation though we have an actively investigated optimizing this yet and expect to realize further improvements and again I I don't keep track too much of how much RAM the typescript compiler is using but this says that it's half so that can only be a good thing in general we also expect to have improved editor responsiveness for all language service operations including completion lists Quick Info like hover and Tool tips go to
definition and find all references as part of this effort we'll also be moving to the language server protocol or LSP a long-standing infrastructural work item to better align our implementation with other languages now they actually talk about this in the recent episode of syntax the fact that the current typescript compiler doesn't actually implement the language server protocol even though it was the inspiration for the LSP but this new native Port does support the LSP so you're going to get that performance benefit inside of your editor when it's providing all of these autocomplete and everything else version roadmap our most recent typescript release was 5.8 with 5.9 coming soon the js-based codebase will continue development into the 6X series and typescript 6.0 will introduce deprecations and breaking changes to align with the upcoming native codebase now this is huge and I'm really glad that the typescript team is thinking about this early on because we don't want a situation where moving to the new native compiler is going to break so many things and you have to change a bunch of project settings so this is going to be a slow on-ramp essentially you can upgrade to six it's going to add
some deprecation warnings and then once those deprecation warnings are gone you're pretty much ready to just upgrade to the native compiler and get all of those speed improvements when the native codebase has reached sufficient parity with the current typescript will be releasing it as typescript 7.0 so there'll be a clear indication if you're using version six or earlier it's the typescript implementation if you're using version seven or later it's going to be the native implementation this is still in development and will be announcing stability and feature Milestones as they occur for the sake of clarity we'll refer to them simply as typescript 6 JS and typescript 7 native since this will be the nomenclature for the foreseeable future so yeah again a clear naming difference if you see something that's typescript 7 you're going to know that it's using the native compiler you may also see us refer to strata the original typescript code name and Corsa the code name for this effort in internal discussion or code comments while some projects may be able to switch to typescript 7 upon release others may depend on certain API features Legacy configurations and other constraints that necessitate using typescript 6 recognizing typescripts
critical role in the JavaScript development ecosystem will still be maintaining the JS codebase in the 6.x line until typescript 7 plus reaches sufficient maturity and adoption now this is great to hear because there are going to be some projects that can't immediately upgrade to version 7 but the fact that they're going to be maintaining them in parallel is huge so that you know you're going to get all of the benefits until you're completely ready to switch to the native version our long-term goal is to keep these versions as closely aligned as possible so that you can upgrade to typescript 7 as soon as it meets your requirements or fall back to typescript 6 if necessary next steps in the coming months we'll be sharing more about this exciting effort including deeper looks into performance a new compiler API LSP and other topics we've also written up some FAQs on the the GitHub repo to address some questions we expect you might have finally I also invite you to join us for an AMA at the typescript community Discord on March 13th you can see the times here according to your time zone so this is huge I for one am super excited about faster editor experience faster compile times faster CI builds
this is great I love the direction that TPT is headed in here and I can't wait to uh actually try out the new compiler I'll run some of my own benchmarks and let me know in the comments do you think this is a good move for typescript do you disagree with their choice of go let us know down below uh and also if you want to hear from the creator of typescript and also the principal product manager of typescript check out the most recent episode of syntax where they dive deep into all these architecture decisions and what's to come for version 7.0 that's it for this video I'll see you later friends
Quote it with credit and a link. Quoting Syntax