Adding static typing to Python

Peter Milliken peter.milliken at gtech.com
Mon Feb 18 19:07:19 EST 2002


There is no such effort to my knowledge. There is a tool called PyChecker
that attempts to fill the gap, I have no experience with it though.

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 suspect that
it is from a background of ignorance and lack of metrics i.e. how much time
is lost in their projects to misnamed variables etc? 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. 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. 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" :-).

Personally, I have used Python for several small, personal projects and the
odd "script" that searches text files - even here, the only perceived
advantage is the library support, I often wonder whether I wouldn't be
better off using my real language of choice (Ada) because of it's strong
typing - it too has interfaces to the standard GUI tools etc. My next
personal project will not be in Python, it is a "cute" language and allows
some nice facilities i.e. creating a script at run-time and then running it
can be very powerful in the correct circumstances - so I will probably use
an Ada-Python API for these situations and get the best of both worlds :-).
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.

Good luck,
Peter

"Alexander Jerusalem" <ajeru at vknn.org> wrote in message
news:24c39b2c.0202181531.187fad4c at posting.google.com...
> Has anyone heard of plans to add static type checking to Python? I
> like Python very much but I don't use it for bigger projects because I
> fear the testing effort. For example I just refactored a rather large
> Java codebase. And when I change a method name for example, all I have
> to do is run everything thru the compiler and it will show me all
> places in other classes where this method is called, so I can go there
> and chenge the method call as well.
>
> In Python I'd have to test the whole software suite including each and
> every branch in each and every if statement to be sure that I didn't
> forget something. To build such a test suite would take almost as long
> as it takes to build the whole software and I'd have to maintain the
> test suite as well. That's just unafordable.
>
> On the other hand, Python is the best language that currently exists
> and I would like to use it on bigger projects not just for prototyping
> as some suggest.
>
> Regards,
> Alexander Jerusalem





More information about the Python-list mailing list