Back to blog
6 min read
TypeScript & Go - My take

Hot news of the week - Microsoft announced radical shift to improve TypeScript performance.

TLDR: They are rewriting the transpiler to Go

The discussions are pretty heated.

I am pretty opinionated about TypeScript, I have been using it in prod for 9 years, I have conducted lectures and presentations about it and I have even contributed to it, so I actually have some thoughts about the shift.

The Bad

Moving away from JS

TypeScript compiler currently is written in TypeScript and runs on JS engine. That’s kinda cool that the compiler is self-hosted, but also serves as a pretty damn impressive example of a complex JS project.

It is not the most idiomatic TypeScript example out there, but it definitely pushes boundaries of language application. Reading the code is kinda fun, it is easy to understand and navigate it. All the tooling around the language is there, so it is full-stack TypeScript all the way down.

Having such a complex project written in the language is very beneficial for the language itself. Like, a new tooling is made, optimizations are discovered or pushed to the language specification.

I love TypeScript, I think it is one of the best general programming languages out there currently, and I go all in into it. Having compiler written in TypeScript actually motivated me to contribute to it. I love TypeScript, so writing more TypeScript for the benefit of TypeScript is a nobrainer.

Was the compiler written in Go or anything else - I probably would never even attempt learning how the compiler works. Having compiler written in another language kinda shrinks the contributor circle to the programmers who are experts in both TypeScript and Go.

Not going for .NET

I am coming from .NET background and I also love .NET, C# and F#. Anders Hejlsberg, being author of both C# and TypeScript, made an unexpected choice of Go lang to go further. That’s fair, there’s no other person on the planet who is more qualified to make the right choice, and I believe in Anders. However that leaves a bad taste in my mouth.

I am going full .NET in my career. That’s an amazing platform - very easy to learn, to write and run. You can do anything with C#, and it indeed is being used everywhere, starting from embedded, through gamedev and to enterprise. That’s beautiful how easy and powerful at the same time C# is. C# already powers probably the best compiler in the world - Roslyn. It seem to be an obvious pick for the native TypeScript compiler, yet it isn’t?

As a .NET developer I would love for new TypeScript compiler to be written in .NET. Not only more people could contribute to it (I believe TS+C# overlap is bigger than TS+Go). Most importantly - that would be a great PR for the C#. Many developers still remember WinForms era C#, when it was commercial and windows only. It is not anymore, and not choosing it for the big project within the same company (Microsoft) hurts it a lot.

Apparently there are some shortcomings of .NET versus Go, like not so sophisticated native AOT and mandatory bytecode step, but wouldn’t that be great to actually improve C# as a part of the project? Choosing C# would also bring more JS interop and ecosystem to .NET which is also great for .NET. Instead, .NET is being left behind.

If even Microsoft is not using C# for its ambitious projects, then why should I?

Sidetracking TypeScript 7 from TypeScript 6

Official plans are to release stable native port as a TypeScript 7, while TypeScript 6 will remain on JS. It’s all over .NET 4.8 vs .NET 5 again. Or Python2 vs Python3.

It was a headache to upgrade to .NET 5 (aka .NET Core) from .NET 4.8, and it still lives parallel to new .NET. Not as brutal as Python2 and Python3, which both coexist and receive updates together, but still.

Meme from the future:

> Package readme says it uses "TypeScript"
> Look inside
> TypeScript 6

The Neutral

Not going for Rust

Sucks for Rust bros, but whatever. Rust is a fine language and there are many existing projects in JS space - Prisma ORM engine (though moving to TypeScript now. How poetic.), Turborepo, NextJS compiler, SWC, Deno, even STC. It might seem that basing TypeScript compiler on Rust would be a good synergy and a the whole ecosystem would benefit. But yeah, no hard feelings about Rust, so whatever.

The Good

Faster TypeScript

Oh yeah, that’s cool! I can’t really say that I experienced slow tsc build firsthand and performance is something which bothers me, but I have definitely experienced slowness of editor speed (language server), and I am very excited about DX improvements!

Moving Forward

TypeScript was stagnant lately. I understand that it is due to it being mostly complete stable, but still, there weren’t many exciting new features in the latest 10 or so releases. Some issues, which I track, are not being closed for years and some were closed as “not feasible”. Now there’s a chance, when compiler moves to a new tech, is faster and cooler, that there will be a fresh influx of new contributors, and there will be higher drive to ship new cool stuff. Anyway, I love seeing progress!

To wrap it up

The news came out of nowhere, honestly. I did not follow TypeScript development for some time, so it really caught me by surprise.

I am a bit sour that my favorite language, which would also be the most obvious choice, was not chosen. That makes me reconsider tech stack I decided to build my career on.

I will also finally bite the bullet and learn Go.