[Types-sig] Re: Static typing considered HARD

Stephen Purcell steve@websentric.com
Mon, 13 Dec 1999 18:46:39 +0100

Paul Prescod wrote:
> Stephen Purcell wrote:
> >
> > This is a cut-down version of a real and justifiable example. Try doing
> > that in Java with reflection and without resorting to 'instanceof' or
> > 'Class.isInstance()'.
> What you're saying is that I can't emulate Python's dynamic features
> without using Java's dynamic features. I would agree with that assertion
> -- but I'm not convinced it is relevant. instanceof is part of the
> language core and isInstance is a reflective feature.

Thanks, Paul, for noting the lack of clarity in my comment, which I
shall endeavour to remedy:

The dynamic nature of Python's exception handling is an intrinsic
language property that cannot be exactly mirrored in Java's exception
handling, using reflection or otherwise. No 'catch' clause in Java will
ever work the same way as Python's 'except', and by "resorting to
instanceof or isInstance" I meant a subversion of the 'catch' clause's
fundamental semantics:

abstract class Test {
   private Class FAILURE_ERROR_TYPE = AssertionException.class;
   void run(Result r) {
     try {
     catch ( Exception e ) {
         if ( e.getClass() == FAILURE_ERROR_TYPE ) {
         else {

This is not the same language construct as the Python version.

Your argument is that any functionality implemented in a
dynamically-typed language can be mirrored in a statically-typed
language. Of course that is true, given enough code. It does *not* imply
that the features of the statically typed language are compatible with
those of the dynamically typed language, nor that their introduction is
desirable and technically possible.

It seems to me that the whole static-blah thing clashes with fundamental
choices that Guido made when designing Python, and those choices are
presumably a large part of Python's appeal and success. I would never
presume to second-guess the needs of Python's users.

Static typing works very well in Java and suchlike, but those are
different languages, and the people who cannot live without static
typing use them instead of Python (and Smalltalk).

The rest of us, who do not expect perfection to consist of the union of
all possibilities, use Python when appropriate and keep in mind its

There's something special about Python's elegance, and losing that
elegance by a Perl-5-like process of cluttering would be enough for me
to abandon the language, and move on to the next 'clean' thing. I care
enough to have posted this opinion, but not enough to try to influence
Python's development.

The booing to which David Ascher alluded in his posting may indeed have
been 'just' an emotional reaction to the proposal, but I challenge any
avid Python user to fully describe his or her enthusiasm for the
language in purely technical terms. I use the language because it
somehow makes me feel good. When it no longer gives me that feeling,
I'll stop using it. Static typing would have that effect. I suspect that
other avid users such as Uche would also stop.

Rational? Not entirely. I don't expect anyone to care what I think or if
I abandon Python in the future, and I certainly don't imagine that any
rational argument I might provide for my opinion would change anybody
else's mind. I'll avoid the fray, and vote with my feet when the time

Steve Purcell                   Squadron Leader
WebSentric AG,       http://www.websentric.com/
____"Would you like to look at my Python?"_____