Re: Static vs. Dynamic typing

From: Christopher Barber (cbarber_at_curl.com)
Date: 09/10/04


Date: 10 Sep 2004 11:01:52 -0400


"Ilja Preuß" <it@iljapreuss.de> writes:

> Cristiano Sadun wrote:
>
> > It just came to me that STC can be seen as a test in itself - in TDD
> > sense: it can be executed before the functionlity is written or
> > available, then fixing the code makes it pass the test. "execution"
> > is the set of type- check steps of the compiler.
> >
> > For example, trying to invoke an unexisting method in a class (this
> > example works better for OO rather than procedural, since methods are
> > part of the type definition) results in a test (compilation) failure;
> > or not having a return statement of the proper type; etc.
>
> A nice example. When using a dynamically typed language, the same tests
> fails, too, because of the same problem (object does not understand
> message) - just at runtime instead of compile time. So in this specific
> case, the compile time check doesn't seem to buy us anything, as far as I
> can tell...

Without static checking this will only fail if the call is actually executed
during testing. All it takes for the static check to fail is for the code to
be compiled. Without static checks it is more important that your tests cover
every line of code and more thoroughly as well. If you consider the static
declarations themselves to be tests, then using them really shouldn't be any
worse than writing tests.



Relevant Pages

  • Re: RAD vs. performance
    ... you have a statically typed language. ... have a dynamically typed language. ... Aside from being an incorrect definition of dynamic typing, ... A "dynamically typed" language which checks errors at compile time can ...
    (comp.lang.misc)
  • Re: Static vs. Dynamic typing
    ... >> When you do TDD, compile time and runtime are virtually equivalent. ... >> tests once the code compiles, and flags test failures in the source ... >> Cheers, Ilja ...
    (comp.object)
  • Re: How to conditionally use a specified module
    ... that will still fail if the boolean value is set at runtime since use ... executes at compile time. ...
    (perl.beginners)
  • Re: [patch] Real-Time Preemption, -RT-2.6.12-rc4-V0.7.47-06
    ... I actually had it produce a link-time error at first. ... > wanted so much to make it fail at compile time that I screwed it up and ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: knowing the interfaces that an object implements
    ... > the IL instruction isinst to make the determination. ... The "if" does, but the call to Dispose should fail at compile time, ...
    (microsoft.public.dotnet.framework)