Live data from Hacker News

Reservations about TypeScript

daviesgeek.com

31–34 of 34 posts

Re: Reservations about TypeScript

#31
post #8

> TypeScript compiles down to JavaScript, which doesn’t have types or type checking, it’s impossible to have actual type checking. The TypeScript compiler is great at checking at compile time, but at the end of the day, it’s impossible to actually check the types. I'll point out that C/C++/Haskell compiles down to Assembly, which doesn't have types or type checking. GCC/LLVM/GHC is great at checking at compile time,…

Additionally, there's Elm which compiles to JS and its most memorable claim to fame is that it's a JS framework where "runtime errors are always a compiler bug".

Re: Reservations about TypeScript

#32
post #18
post #8

> TypeScript compiles down to JavaScript, which doesn’t have types or type checking, it’s impossible to have actual type checking. The TypeScript compiler is great at checking at compile time, but at the end of the day, it’s impossible to actually check the types. I'll point out that C/C++/Haskell compiles down to Assembly, which doesn't have types or type checking. GCC/LLVM/GHC is great at checking at compile time,…

Good point. That being said, TS does suffer from something unique, in its JS interop. If my C program interfaces with a C library, I have great certainty that all of these were compiled at some point, and the types are sound (as much as C allows, at least). In TS, if you're lucky a library you consume was written in TS, so you've got high certainty that the typings it comes with are really good. Less lucky: the devel…

Even less lucky: coding in vanilla JavaScript. In the days before Definitely Typed, I still got a lot of mileage out of types in my code alone. It felt immensely more apt then using JSDoc to document types everywhere.

In my experience, even if you don't have types for a third-party library, you can get away with adding types for the interfaces you care about.

Re: Reservations about TypeScript

#33
post #6

First point: "I found a bug but can't give an example." Second point: "It adds a feature that's different from a similar language." These are not persuasive arguments. I'm not trying to be unkind, but the first point is totally unsupported and the second doesn't elaborate on what's bad about classes besides that another language also has classes.

Definitely agree on the first, that's a good point. I probably should've been better about how I presented the data. "TypeScript still compiles down to JavaScript. It has no way of actually checking types." That's my point. Maybe I should make it more obvious in the article :) I'm not complaining about the fact that TS has classes or types, it's that TS compiles down to a language that has neither.

> it's that TS compiles down to a language that has neither

What languages compile down to a language that has either? Most languages compile down to either machine code, or virtual machine code.

Re: Reservations about TypeScript

#34
If you're curious about or skeptical of TypeScript, do yourself a favor and check out the source code sometime: https://github.com/microsoft/typescript

It's a work of art, everything is so practical and (relatively) easy to understand. Even better, it's written in TypeScript, so you can open it up in an editor with TS support and follow/jump to any reference with confidence. I've only learned about compilers vaguely through osmosis, but I was able to extend its JSX syntax processing (admittedly that part does seem a bit bolted-on) to output JSON for my wonky framework side-project in a few hours: https://github.com/guscost/protozoa-tsx

Post reply on HN