Remix.run Logo
recursive 3 days ago

This is the real-est static typing that exists. "Static" refers to build time. By definition static types are checked at build time, not run time. If you want types to be checked at run time, that's called "dynamic" typing.

mplanchard 3 days ago | parent [-]

Sure, you're technically correct. But TS is compiled in to JS, which is dynamically typed at runtime. You're still ultimately in a dynamically typed language.

In addition, in a typical statically typed, compiled language, your only place where you interact with data that isn't guaranteed to be type-conformant is at a foreign function interface, whereas in Typescript all your interaction with third-party libraries is via regular JS and may or may not be type conformant.

throwaway894345 3 days ago | parent | next [-]

Rust compiles into WASM, x86, etc, which are dynamically typed for all intents and purposes. They certainly don't understand or enforce Rust's type system invariants any more than JavaScript enforces TypeScript invariants. If you call a Rust function from WASM and pass it malformed data, the WASM runtime will happily execute it.

(pretty sure WASM actually has some integer types, so I guess maybe it is technically "statically typed" but not in any interesting sense--we could similarly say that JavaScript is "statically typed" because every variable has a static "any" type).

recursive 3 days ago | parent | prev | next [-]

Is there such a thing as a statically typed language? CPU opcodes don't type-check their parameters.

johnfn 3 days ago | parent | prev [-]

And Go/C/Rust compiles to ASM, a dynamically typed language at runtime.