Every programmer faces the same tension: static typing catches bugs before the program even runs, but annotating every variable slows you down; dynamic typing lets you move fast, but errors only surface at runtime — sometimes days after they were introduced.
Gradual typing, introduced by Jeremy Siek and Walid Taha in 2006, dissolves that tension. In a gradually typed language you can annotate some variables and leave others with the dynamic type (sometimes written ? or Any). The type checker ignores in static analysis; at runtime, every crossing of a typed/untyped boundary becomes an explicit cast that checks the contract on the spot.
The key insight is the blame theorem: when a cast fails, the language runtime can always point its finger at exactly the piece of code that broke the contract — the typed side, the untyped side, or neither. You get the safety of static typing where you want it and the flexibility of dynamic typing where you need it, with no silent errors in between.
Languages like TypeScript, Python (with mypy/pyright), Racket, and Dart all embody different points on this spectrum. Gradual typing is the formal foundation underneath them all.
Comments
Loading comments...