Class Browsers vs Static Types (Re: Inefficiency of __getattr__)

Quinn Dunkan quinn at seniti.ugcs.caltech.edu
Thu Oct 5 16:12:04 EDT 2000


On 5 Oct 2000 19:18:34 GMT, Mark Carroll <carroll at cis.ohio-state.edu> wrote:
[ not sure who wrote what :) ]
>>I actually disagree about your every line of code comment.  Perhaps
>>not repeatedly in regression tests or automated testing, but I do
>>expect every line of code that I write to be executed during
>>development at some point - even if I have to write dedicated code to
>>do it.  So pretty much the same stuff that the compiler would catch my
>>tests will catch.
>
>You obviously missed my qualifier, "Unless you have a very well
>designed test suite". Clearly you usually do, but that's too rarely
>the case.

[ ... ]

>>Of course, that's not much different from finding semantic or
>>behavioral errors cropping up some time after code is in use, but when
>>the inputs to the system begin to change.
>(snip)
>
>Yes. Most of my bugs happen to be the sort that a type checker will
>catch, though. No doubt one's mileage varies.

I'll chime in and agree with you here.  And note that a "very well designed
test suite" is never easy to implement, but sometimes it's significantly more
work than writing the program in the first place.  For example, I tend to
write lots of medium-sized gluey things (which is a real strength of python, I
think).  I try to keep the interfaces to a minimum, but due to their gluey
nature they're doing lots of interaction with external objects.  Faking up
those interfaces to make sure I can hit all the boundary conditions is a lot
of work.  And what if I forgot something in the test suite?  "bugs of
omission" in the test suite can easily hide real bugs in the program.

Figuring out how to test more completely and easily is an area I'm quite
interested in at the moment.

To answer the "original" question briefly, here's what I see as the three
advantages of static typing:

safety, documentation, and efficiency

(I do like the idea of "executable documentation" like DbC and such)

Disadvantages are

complexity (type systems add a lot to a language), and inflexibility


In the debate about whether the "safety" benefit is really that much of a
benefit, I'd say it is, but it really depends on what you're writing.  But
I don't think anyone's claiming it magically makes your programs perfect.  It
has a limited applicability to a certain class of bugs, but most of my bugs
are in that class :)

Perhaps people get turned off of these things because the type systems of C
and its mutations can be so awkward, just like people got turned off of
garbage collection from early algorithms that were not so great (although it
looks like this opinion has changed, maybe due to java marketing).

Of course, the most modern languages are the hybrids that try to glean
advantages from both "schools": type annotation or inference for dynamic
languages, and elaborate polymorphism/genericicity and dynamic binding for
static ones.



More information about the Python-list mailing list