Re: Static types hurt by their name



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.

--
Chris Smith
.



Relevant Pages

  • Re: RAD vs. performance
    ... All of the implementations are either slow to compile ... exactly the same for a dynamically typed language as it is for Ocaml? ... Then you're implementing static typing. ... course, I think you must), then it follows that dynamic typing does NOT ...
    (comp.lang.misc)
  • Re: dynamic vs. static: the age-old debate
    ... static typing, ... whereas dynamic typing means no such restriction is imposed. ... E.g. many languages have ...
    (comp.lang.misc)
  • Re: ADA Popularity Discussion Request
    ... creative imagination do not face immediate real-word risks; ... First, for static typing, let's repeat that "Ada is for problem space". ... I guess that dynamic typing provides description of "event space", that is, ...
    (comp.lang.ada)
  • Re: dynamic vs. static: the age-old debate
    ... static typing, ... whereas dynamic typing means no such restriction is imposed. ... E.g. many languages have ...
    (comp.lang.misc)
  • Re: Which programming language is better to start
    ... > Type inference is visible when you have static type checking. ... > If you can't demonstrate the equivalent Lisp code then just say and we ... >> Do I have to repeat that Lisp has both dynamic and static typing? ... > Dynamic typing has no advantages in my experience. ...
    (comp.programming)