
Types, types: static vs. dynamic -- classification
I lost the trace of the thread of C++ static typing vs.
Smalltalk dynamic typing. The debate is interesting,
but we cannot have any conclusion if we focus on the
terminology only.
There are a number of different ways to define typing.
I cannot tell which one should be the standard. Each
langauge has its own definition. The difference is
especially remarkable between dynamic languages like
SmallTalk and static languages C++ and Eiffel. Therefore,
do not pay attention to the word itself, instead, focus
on the definition associated with the word.
The following list is helpful for you to identify
which kind of type system a language has:
1. Type vs. typeless
* Does a language provide types?
Prototype languages like Self do not have type at
all. Objects are created by cloning exisiting
objects.
For languages have types, we have:
1.1. Dynamic typing system vs. static typing system
* Can type (subtype) be defined at run-time?
or, is the class hierarchy dynamic?
For dynamic typing system, we further have:
1.1.1. Dynamic typing vs. static typing
* Can we change the state of a type
at run-time? Or, can we add/delete
methods or instance variables to/from
an existing type dynamically?
Some dynamic typing system does not
allow the state change of a type once
the type is created.
2. Typed vs. untyped
* Does a name declaration need the specification of
its type?
SmallTalk is an untyped language because variables
are untyped.
Further, for typed language, we have:
2.1. Dynamically typed vs. statically typed
* Can a declared name assumes different types
in a given range at run-time?
C++ is dynamically typed in terms of pointer
declarations. Eiffel is dynamically typed in
terms of non-primitive variable declaration.
Dynamically typed is often refered to poly-
morphism.
Untyped lnaguage is an special case (extreme)
of dynamically typed langauges.
3. Static type checking vs. dynamic type checking
* Does a language needs dynamic type checking to ensure
type safe?
4. Type safe vs. unsafe
* Can a language ensure that all type errors should be
detected?
For type safe languages, we have:
4.1. Static type safe vs. dynamic type safe
* Can a language guarantee no run-time error
(after comiplation)?
Two important notes:
(1) Languages that requires run-time type check can be
statically safe;
(2) Dynamic typing system with static typing is the maximum
benefit point between statics and dynamics.
David