[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dynamic vs. static typing
"Anton van Straaten" <email@example.com> writes:
> An ideal typesystem should allow static expression or detection of the
> things that can be known statically, without significantly inhibiting our
> ability to manipulate things that can only be known dynamically.
This sounds reasonable...
> Pure DT languages say "we dunno how to provide that, so we're not
> going to offer any static analysis whatsoever".
...but this is a caricature. Any compiled language does *some*
sort of static analysis.
If there is some feature of the language that cannot always be
statically decided, and you are unwilling to restrict usage of the
feature to the statically decidable cases, then there needs to be
runtime support for that feature. If there is runtime support for a
feature, then static support of the same feature, however desirable,
is no longer strictly necessary.
DT languages say ``no one can statically analyze all uses of feature
X, but we *can* dynamically ensure that any particular usage of
feature X will be checked for correctness. Since it can be proven
that complete static analysis is impossible so we will still need the
dynamic tests for when the static analysis cannot decide, and since
even in those cases where it *is* possible, it offers no more safety
than already exists, why bother?''
The answer, of course, is that the sooner you find out something, the
So it is a tradeoff: reduced language power vs. redundant analysis
vs. early answers.
> I don't believe that this choice, as pragmatic as it may be,
> represents the ultimate in language capabilities.
I agree. There is a lot more that could be statically checked.
Nonetheless, I prefer to start from the `pure DT' side and add static
analysis rather than start from the `pure ST' side and add dynamic
abilities. I believe that there are far too many interesting programs
that cannot be statically analyzed.