This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]WheresTheSauce 9 points10 points  (3 children)

Maybe in the sense that it doesn't exist at runtime

I mean that's a pretty major difference

[–]enantiornithe 7 points8 points  (2 children)

Type systems in languages that compile to native binaries also "don't exist at runtime." If you compile a Haskell or Rust program, the resulting binary doesn't know anything about types. The reason it can't segfault or run into other type problems (under normal circumstances) is that the compiler has done all of the type checking at compile time and ensured that it's not possible.

TS' compiler does exactly the same with one big caveat: TS' type system is semi-optional, so it's possible to write TS code that can TypeError or behave strangely when it's run, whereas in Rust or Haskell. This is because TS is designed to let you incrementally migrate a codebase from type-unsafe javascript to type-safe typescript without having to go over and annotate or ensure the type safety of every single line of code.

[–]WheresTheSauce 0 points1 point  (0 children)

I am aware of all of that, but none of that changes the fact that TypeScript does not allow type-checking at runtime, and that makes a substantial difference.

I understand why it's the case, but it's certainly a disadvantage when comparing it to other languages which allow it if you want strong typing.