does lack of type declarations make Python unsafe?

David Abrahams dave at
Thu Jun 19 04:57:08 CEST 2003

bokr at (Bengt Richter) writes:

> On Wed, 18 Jun 2003 10:25:54 -0400, David Abrahams <dave at> wrote:
>>Alex Martelli <aleax at> writes:
>>> But this has little to do with the need of 'type declarations'.  I
>>> suspect that a statically typed language would also be better off
>>> without them, relying on type inferencing instead, a la Haskell (and
>>> Haskell's typeclasses to keep the inferencing as wide as feasible),
>>> for example.  But I have no research to back this up;-).
>>I don't have any first-hand experience, but the experience of friends
>>of mine who have used Haskell is that it can be exceedingly difficult
>>to locate the source of a type error when it does occur, since the
>>inference engine may propagate the "wrong" type back much further than
>>the source of the error.
>>Furthermore, if you do everything by inference you lose the
>>explanatory power of type declarations.
> But what does "type" really mean? ISTM that in the static typing world
> "type" mostly identifies a type of *representation* -- i.e., things that
> have compatible memory layouts. 

That's a very primitive notion of type, and not at all what is meant
in type theory.

> Of course any Python implementation will have underlying
> *representations* of its entities, but those are not a central
> concern of Python or Python programmers. In fact, UIAM it is a goal
> of Python design to enable programmers to forget about concrete
> representations as much as possible, except for "foreign"
> interfacing.
> I.e., the "types" of Python are more abstract, and are more about
> abstract structure and functional compatibility than underlying
> representation. ISTM "static" typing in this world can't be a direct
> translation of the old concept, unless you are talking about an interface
> to an old-style "statically typed" world, or want to incorporate
> an encapsulated chunk of that into python.

I think most of the above is answered in my reply to Alex, which I
refer you to.

Dave Abrahams
Boost Consulting

More information about the Python-list mailing list