3 ms·
Not necessarily. Since the word "typed" language is not well-defined. For example, typescript is a fantastic language for marshalling data and UI state since i
by meghprkh 4mo ago
Not necessarily. Since the word "typed" language is not well-defined.
For example, typescript is a fantastic language for marshalling data and UI state since it uses substructural typing instead of nominal typing. Libraries like kysely / other ORM libraries are great examples too and easy to use, whereas in fully typed languages like Rust you would end up having to use a macro library like sqlx or having to define structs for each of your types (which would increase compile time & size)
- galaxyLogic 4mo agoAs I understand it TypeScript does not enforce types at runtime. Am I correct? If so that would signify to me it is not a "typed language", like say Java for instance. Types in TypeScript are more like "annotations" for docujmenting the program. Am I correct?
- dnautics 4mo agoits statically typed, but not runtime typed!
- abustamam 4mo agoI have never worked in Java. But you can certainly ship TypeScript code that does not pass typecheck and it'll run fine in the browser because the browser runs Javascript, not typescript. Obviously a decent build process will prevent code that fails typecheck from shipping, but that's not a language feature. For runtime types I've leaned on Zod or Effect schema,which can also generate static types for you.
- bluepnume 4mo ago[dead]
- tancop 4mo agoits more than annotations, your code fails to compile when you get a type error at least with strict settings. if it type checks and fails at runtime that means youre missing input validation or using bad declarations for third party/legacy untyped code. or using some escape hatch like `myValue as unknown as MyType` in the wrong way.
- whstl 4mo agoLots (most?) of statically typed languages also do near zero runtime checking. They naturally use types for compilation, but the type system is trusted to forbid some invalid states. Underneath it’s all bits and bytes. Even in safe languages you need deserializers/parsers/validators. Typescript actually ends up having more checks because it runs Javascript underneath (although some might argue those barely count).
- DonaldPShimoda 4mo ago> Not necessarily. Since the word "typed" language is not well-defined. This depends entirely on context. In the Benjamin C. Pierce school of thought (a common choice in programming langauges research; see his book Types and Programming Languages, 2002), "typed" means what we typically call statically typed, i.e., the language employs a static analysis to prevent the compilation/execution of (some subset of) faulty programs. Meanwhile, languages that are commonly called "dynamically typed" are, in this school of thought, not typed (or "untyped"). (TAPL provides a more rigorous definition, but it's in the other room and I am lazy.)