# Today I Learned

Some of the things I've learned every day since Oct 10, 2016

## 93: Subtypes (Programming)

Let $A, B$ be data types in the type system of a programming language. To say that $A$ is a subtype of $B$, often written $A < : B$, means that objects of type $A$ can be used where objects of type $B$ are expected. That is, $A$ is a more specific version of $B$ in some sense. (Equivalently, $B$ is said to be a supertype of $A$.)

Subtyping forms a reflexive and transitive relation on a given set of types.

An (non-technical) example would be $P < : F < : B$, where $P$ is the type of penguins, $F$ is that of flightless birds, and $B$ is that of birds. A penguin is acceptable where a bird or even a flightless bird is expected, but conversely not any bird will do when a penguin is expected.