← Back to context

Comment by zarzavat

7 hours ago

There are precisely two languages that make the most sense to implement the TypeScript compiler in: Rust and TypeScript itself.

A Rust implementation will have the fastest compilation speeds, memory safety, can easily be compiled to WASM, or compiled to a native node module.

A TypeScript implementation provides the most convenient way for TypeScript code to use the typescript package as a library. Pure JS, no native code or WASM dependencies. No FFI tax, can be jitted.

Go was always a compromise to make a port easier for humans. Go's GC makes it easier to keep the general code structure from the TS implementation. However that GC is also a liability, you sacrifice speed and embeddability.

Personally I'd prefer they went back to TypeScript for the reference implementation, and used Rust for the performance implementation. Go doesn't bring anything to the table anymore.

> There are precisely two languages that make the most sense to implement the TypeScript compiler in: Rust and TypeScript itself.

Incorrect. I can maybe agree that those are the only perfect languages to implement tsc in them (if there is such thing). But in the real world, "perfect" does not actually mean "it's a good idea". Go made the most sense to port to (especially before agents), more than Rust (although C# could also be a good idea IMO).

  • C#'s embeddability/interop story is even worse than Go's; IIUC this was the primary reason they chose not to use it.

    • C#'s embeddability/interop story is as good or better than Golang's. The primary reason they chose not to use it was that C# was seen as too verbose compared to the TS original source. In particular TS used a lot of top level functions and bare/anonymous data types and while C# has picked up top level function support it's still not "idiomatic" and while C# has a long standing anonymous data type support it's not very "ergonomic", certainly not compared to TS structural typing. Golang's traits are a bit more ergonomic by comparison, unfortunately.

      I also still think C# would have been a better long term option for maintainability, but I'm not on the Typescript team and didn't get a vote, and I can understand their methodology even if I don't agree with it.