What is a type system?

Definition

Types describe properties such as whether a value is a number, text or a structured record. A language uses rules about those categories to check operations, function arguments and other relationships, sometimes before execution and sometimes while a program runs.

The guarantees depend on the language and its checking rules. A program satisfying its type rules can still have incorrect requirements, logic errors or security defects, so type checking complements rather than replaces other verification.

ELI5

A type system is like checking that each part of a program receives the kind of information it is designed to use.

For example, a function expecting a numeric amount may reject a text label instead of proceeding with an unsuitable input.

Does passing type checks prove a program is correct?

No. Type rules establish specific properties and cannot by themselves establish that the program meets every intended requirement.

Must types always be written explicitly?

No. Some languages infer types from the program while still applying rules to check how values are used.

  1. Vaibhav Gupta in a blue top beside the blue and white headline Build at Agent Speed? on black.
Definition card for type system: What is a type system?

A type system assigns and checks categories of values and expressions to constrain which operations a program may perform.