Hacker News new | ask | show | jobs
by esperent 2205 days ago
It's important not to read this as a critique of Typescript. Rather, it's a note that it's not a good fit for this one particular performance critical piece of code.

It sounds like they are discussing the central code runner of deno. I would have expected this to be compiled to JS in any case, but it seems like they are compiling the runner, then compiling user code. Of course that's slow. It's also not representative of a normal TS use case, which is unfortunate because I expect we'll see this discussion shared all over the web as an argument for dropping TS.

3 comments

a) Any static type system has things that it can't express elegantly or maybe at all. In my experience, the more "meta" your project is, the more you're going to run up against these bounds. So it makes sense that this could be the wrong use-case for TypeScript.

b) There is a valid, broader point to be made here that while TypeScript itself doesn't carry any runtime overhead (by design), it can in some cases force you to contort your code, so that it can be type-verified, in ways that have a runtime impact. In my experience (a couple of years writing TypeScript professionally) this is uncommon and not a huge problem, but does happen occasionally. It's also worth noting that the vast majority of these cases can be papered-over using //@ts-ignore, "as" casting, etc. if necessary.

I don’t read that as a criticism of TypeScript at all. That is entirely self inflicted due to a name collision between an identity in their definition file and some weird class extension insanity.

I don’t use classes or inheritance in my own code and it’s incredibly liberating. The result is data structures and interfaces that are primitive and independent, which removes so much fragility.

In my entire experience as a programmer, I can't recall writing a prototype that was not eventually used as production code. If I wrote prototypes in JavaScript, I'd have to start all over again to rewrite them in TypeScript.

Meanwhile, people would be on my ass trying to understand why I can't just simply hook up that decent looking prototype to API and release it.