Re: Static types hurt by their name
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Tue, 27 Mar 2007 10:21:31 -0600
Robbert Haarman <comp.lang.misc@xxxxxxxxxxxxx> wrote:
I think, before we start discussing new names for things, we should
think about what we actually mean by the old names. The first
definitions of static and dynamic typing that I encountered stated that
static typing associates types with variables, whereas dynamic typing
associates types with values. Thus, it was possible to assign to a
variable holding a value of some type a value of another type under
dynamic typing, but not under static typing.
I feel these definitions are lacking, for several reasons.
I certainly agree that they are lacking. Static typing and dynamic
typing are completely different concepts, which both address some of the
same problems. They both go by a name that is derived from the
intuition about the sort of problem they often solve, but the approach
taken to solve the problems is very different. By focusing too much on
the problem, for example, one misses the fact that each technique
generalizes to a very different superset of problems.
Rejecting programs at compile time unless the compiler is convinced the
types are correct is what I now call static typing.
Ultimately, that ends up being a circular definition. I'm omitting some
of the details, but ultimately the only reasonable definition of "type"
in the static sense is "property that is used in static typing". Static
type systems can address all sorts of properties of programs; and they
are properly called types to the extent that a type system addresses
them. Until a type system addresses them, they are often called logic
errors. Because of this, defining static typing in terms of rejecting
programs where the types are incorrect doesn't help much, when you don't
have an a priori definition of incorrect types.
Allowing a program to run unless an actual type error occurs is what I
now call dynamic typing.
Yes, but. The "but" here is that a different definition of "type" needs
to be adopted. Now the "type" is something closer to the intuitive
sense of the term. Things that can be types in the static sense are not
types in the dynamic sense. Java's checked exception handling is
ultimately a kind of type system in the static sense, but it's by
definition impossible to accomplish that goal dynamically, for example.
With these definitions, it seems clear that static typing would more
appropriately be called "early" and dynamic typing "late".
This would gloss over the differences far more than the current
terminology, and be even more misleading.
I wonder where all this leaves soft typing: emitting warnings when the
types don't seem correct at compile time, but letting the program run
until an actual error occurs anyway. Right on time typing? ;-)
No, it's both static typing (in a way that doesn't prevent compilation
from succeeding) and dynamic typing. It is no less of one or the other;
it is both at once.
- Prev by Date: Re: Static types hurt by their name
- Next by Date: Re: Vista security
- Previous by thread: Re: Static types hurt by their name
- Next by thread: Re: Static types hurt by their name