Type System Evolution
A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute. Over decades, type systems have evolved from mere memory descriptors into powerful theorem provers.
1. Dynamic vs. Static (The Early Divide)
* **Dynamic Typing (Python, JavaScript)**: Types are checked at runtime. Fast to prototype, but refactoring large codebases becomes brittle. "Duck typing" rules the design.
* **Static Typing (C, Java)**: Types are checked at compile time. Prevents entire classes of runtime errors but traditionally required verbose, redundant annotations (e.g., `String s = new String();`).
2. Type Inference (Hindley-Milner)
The breakthrough of languages like Haskell, OCaml, and later adapted into Swift and Rust, was advanced **Type Inference**.
Using algorithms based on the Hindley-Milner system, the compiler can deduce the most general type of an expression without explicit annotations.
* **Result**: The safety of static typing with the ergonomics of dynamic typing.
3. Structural vs. Nominal Typing
* **Nominal (Java/C#)**: Two classes are only compatible if one explicitly declares it inherits from the other, even if they have identical fields.
* **Structural (TypeScript, Go)**: If it walks like a duck and quacks like a duck, it is a duck. Types are compatible if their internal structures match. This perfectly models modern JSON-heavy API interactions.
4. The Frontier: Dependent Types (2026)
In modern formal verification and languages like Idris, Agda, or Lean, types can depend on **values**.
* Instead of just defining a type `List`, you define a type `List(n, Int)` — a list of exactly $n$ integers.
* If you write a function to append two lists, the compiler enforces that the return type must be `List(n+m, Int)`.
* **Impact**: Dependent types erase the line between "compiling" and "proving." A program that compiles is a mathematical proof that its specification is satisfied.
---
**See Also:**
- [Programming Language Evolution](ProgrammingLanguageEvolution)
- [Formal Methods Hub](FormalMethodsHub)