|
|
|
|
|
by tomp
2390 days ago
|
|
You can count the number of type systems that are "logically OK" (the formal terms are sound (doesn't admit wrong programs, unlike e.g. Java), complete (can admit all correct programs (for some definition of "correct"), unlike e.g. Scala), decidable (always finishes)) on one hand. The rest amount to various amounts of hacks - common ones include specifying function parameter types to allow type inference to function, various escape hatches (like Object in Java and interface {} in Go), generics incorrect or limited to various degrees. Subtyping is tremendously hard. The specific hacks implemented in different programming languages are often implementation-specific (and arbitrary), and often result in weird interactions between different language features. Basically, type systems == science (figuring out new things), programming languages = engineering (making new findings useful). |
|
Huh? Rice's Theorem states that any static semantic analysis must either reject valid programs or accept invalid programs. This says nothing about whether a type system is rigorous or hacky.
> common ones include specifying function parameter types to allow type inference to function
It's true that type inference becomes undecidable without annotations for things like dependent types, and there's nothing hacky about that.