[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic vs. static typing



Shriram Krishnamurthi <sk@cs.brown.edu> writes:

> Joe Marshall wrote:
>
>> 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.
>
> Surely I don't need to tell you that this is what well-designed (and
> sound!) typed languages do.  For example, the type systems of most
> typed languages don't even try to prove that array bounds will be
> within checks.  The run-time systems of most typed languages therefore
> insert array-bounds checks.

Of course!  I was talking motivation.  Why is it that array bounds are
not statically checked?  Because:

    a)  you can't *always* statically check them, so unless you
        restrict the usage of array references, you will *need*
        run-time checks.

    b)  since you need run-time checks *anyway*, and since you already
        have them, statically checking array bounds won't give you any
        more safety than you already have.  (earlier detection,
        possibly, proof of certain properties, possibly, but no more
        safety)

>> ...but this is a caricature.  Any compiled language does *some*
>> sort of static analysis.
>
> I have to pick a nit with this terminology.  *Languages* are neither
> compiled nor interpreted.  Individual implementations may take the
> form of a compiler or interpreter (or god-knows-what these days).

Ok, any *compiler* for a language does *some* sort of static analysis.
Therefore, if there exists (or could exist) a compiler for a language,
then *some* sort of static analysis is possible on that language.