does lack of type declarations make Python unsafe?

David Abrahams dave at
Fri Jun 20 16:07:31 CEST 2003

"Donn Cave" <donn at> writes:

> Quoth "Greg Ewing (using" <g2h5dqi002 at>:
> | David Abrahams wrote:
> |> 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.
> |
> | I played with HUGS intensively for a while some time back,
> | and I can attest that this is indeed a problem. I was led
> | to the conclusion that the only way to retain my sanity
> | was to provide an explicit type declaration for every
> | function.
> |
> | This has two benefits -- it helps the compiler catch
> | type errors early enough to actually give you a useful
> | error message, and it helps to document the code.
> |
> | But if you're doing that, you don't get much benefit
> | from type inference, raising the question of whether it's
> | worth the effort of designing a compiler that can do it
> | at all.
> There's a huge difference between optional type annotation
> and a system that requires you to declare the type of every
> single thing.  The latter is a big nuisance, and far from
> helping to document the code it buries the sense of what the
> function is doing in a lot of trivia about its parts.

Clearly that's a matter of opinion.  I'd love to use a language which
made type inference optional, just to see.  Maybe I'll have to start
playing with Haskell.

In the meantime, I'd like to quote a favorite phrase:

   "Explicit is better than implicit"


turning-the-zen-against-itself-ly y'rs,

Dave Abrahams
Boost Consulting

More information about the Python-list mailing list