Types

A type classifies a value and fixes what operations make sense on it. Common ones show up in nearly every language: integers (whole numbers), floats (numbers with decimals), strings (text), and (true/false). The type is what makes 2 + 3 give 5 but "2" + "3" give the text "23" — same symbol, different meaning depending on the types involved.

Types are also a safety net. Adding a number to a piece of text is usually a mistake, and a language that tracks types can catch it — some before the program even runs (statically typed), some only as it runs (dynamically typed). Under the hood every value is just ; the type is what tells the computer how to interpret them.

hierarchy prerequisite related

See the full map →