Description A
type system
is a set of rules that defines how values,
variables and functions may be used in a given programming languages.
A type checker, checks that these rules are enforced. The moment that type checking can be done differs
per type system, but two extremes exist:
- Static type checking: all checking is done before the program is executed.
- Dynamic type checking: all checking is done during execution of the program.
- Hybrid type checking: when possible checks are done before execution, the remaining checks are done during execution.
These different styles of type checking have different trade offs:
- Static typechecking:
- Pro: most errors are found before execution.
- Con: more type declarations have to be written by the programmer and in some situations the type systems limits what can be expressed.
- Dynamic checking:
- Pro: most flexible and expressive.
- Con: errors can only be found during execution.
- Hybrid type checking:
- Pro: a reasonable compromise.
- Con not as safe as full static typechecking.