Adding static typing to Python

brueckd at tbye.com brueckd at tbye.com
Mon Feb 18 19:54:11 EST 2002


On Tue, 19 Feb 2002, Peter Milliken wrote:

> The loose typing of Python is perceived as one of its big features :-).
> There are regular discussions on the usefulness of Python for "larger"
> projects. Many claim that they use it without any problems

I'm one of those people who like to make those sorts of claims. :)

> - I suspect that
> it is from a background of ignorance and lack of metrics

Rather than from ignorance, maybe it's from actual experience using it.
Have you considered the possibility that the claims might be true? In this
job as well as the past few our Python code has always had less time
devoted to developing, testing, maintaining, and refactoring it. It's not
that there's hidden costs involved - we tend to write it and move on to
something else because it just works.

> The only way in Python to find these is through (exhaustive) testing -
> such rigorous testing *requires* you to develop an exhaustive test
> suite that is capable of running periodically i.e. nightly etc to
> catch such errors.

The current state of software development is that large programs need
exhaustive and rigorous testing anyway. The reason that the loose typing
doesn't kill you is that good testing finds misnamed variable bugs like
you cited above as well as bazillions of other bugs.

> Whether the people who support Python for larger projects have the
> discipline within their project team to maintain such an effort is
> unclear - there has been no mention of it at all.

Really? Good testing comes up every single time this topic comes up, and
invariably people talk about how they *do* write tests for their code, and
how good testing helps them find all sorts of bugs.

> So I doubt that the proponents of Python in these instances have any
> idea of the true cost of this language "feature" - they appear to be
> wound up in how quickly they can produce a working prototype (or
> whatever) so I suspect their day to day work involves very small,
> manageable projects where the lost efficiency due to loose typing
> isn't really that noticable for them i.e. they "live with it" :-).

Might be true for lots of people, but nearly every single Python module in
our company's code has either built-in or accompanying tests that run
every night. The same is true for our non-Python code. The dynamic or
static typing of the language makes little real difference - if you don't
test, you overlook bugs, pure and simple.

> When I compile a Ada program cleanly I know that 95% of the bugs are out of
> it - before I even start testing! :-) Of course, it takes me longer to write
> up front but overall development effort (in my subjective opinion - since I
> have no metrics :-)) is that it is much lower.

Whatever floats your boat, I guess. Very few of my bugs (in any language)
are things caught by a compiler and if anything, the warm fuzzies because
the code compiles is often a false sense of security. The 95% seems very
high, even considering Ada's strictness - to that I'd say that with Python
95% of the bugs never make it into the code in the first place. :)

Have fun,
Dave





More information about the Python-list mailing list