PL

On “dynamic typing”

September 9th, 2005  |  Published in PL

The expression “dynamic typing” is internally incoherent and should be replaced with something more accurate. Instead, we should call “dynamically typed” languages what they are: untyped.

A type is a range of values. A typed language, in Cardelli’s magisterial formulation, is one in which variables can be ascribed nontrivial types. Note that this must be a static property! Perhaps advocates of the term “dynamic typing” mean that the type of a variable may change with assignment. Such a claim, however, is vacuously true for untyped languages — the range of values a variable may hold can always change with assignment. (This does not mean that a variable in an untyped language may be ascribed a type!) It should be clear that if the “type” of a variable may change with assignment, then the variable does not have a type at all.

To talk sensibly about types, we should follow Cardelli’s example and decouple discussion of typing from discussion of safety. I suspect that what most people mean by “dynamically typed” is “untyped but safe” — viz., an untyped language in which operations are checked at runtime to ensure that they are valid for the given operand values.