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

Re: dynamic vs. static typing



On 2003-11-25T11:32:47+0100, Pascal Costanza wrote:
> ...but you still have a two-step protocol. Even worse, you can't change 
> the object into one that cannot be turned off anymore as long as you 
> have the object2 reference.

You can't change the object into one that cannot be turned off either,
while turnOff is executing.

> b) The dynamic language gives you a "one-step protocol" for free that 
> simultaneously checks the presence of a feature and invokes it. In a 
> static language, it takes more effort to ensure that your code behaves 
> reasonably in between.

That is easy to achieve with static typing as well:

    if (object.turnOffIfYouCan()) ...

That is, if we mean the same thing by "one-step protocol".  You have
not defined what it means to have a one-step protocol as opposed to a
multi-step protocol.  Saying that dynamic typing gives you a one-step
protocol is like saying that dynamic typing gives you a one-constraint
protocol: what do you mean, and so what?

It takes some effort to make sure that every caller of turnOff() or any
other method that may not be supported catches the possible exception
that may result.  If someone doesn't, then you might call o.turnOff()
and be tricked into thinking that that o doesn't support turnOff, when
in fact o has a faulty implementation of turnOff that fails to catch
exceptions properly.  As demonstrated above, a static language gives you
a "one-step protocol" (according to some reasonable definition that does
not contradict any you have given because you have given none) for free
that simultaneously checks the presence of a feature and invokes it.
In a dynamic language, it takes more effort to ensure that your code
behaves reasonably between trying to invoke a feature and recovering
from its not being supported.

> c) Turing equivalence is boring. Only the stuff that goes beyond Turing 
> equivalence is really interesting in language design.

You have yet to specify anything in dynamic typing that goes beyond
Turing equivalence and static typing, much less prove such a claim.

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Sexy types in action: http://www.eecs.harvard.edu/~ccshan/cs252/usage.pdf
new journal Physical Biology: http://sansom.biop.ox.ac.uk/images/physbio.gif
What if All Chemists Went on Strike? (science fiction):
http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html

Attachment: signature.asc
Description: Digital signature