does lack of type declarations make Python unsafe?

Steven Taschuk staschuk at telusplanet.net
Wed Jun 18 20:52:07 EDT 2003


Quoth Brandon Corfman:
  [...]
> I'm not sure that I would write the best FAQ on the subject: although I 
> could write up the Python community consensus, I don't agree with it 
> fully because I think the advocates of static typing make good points. I 
> think optional static typing has clear benefits for safety in light of 
> the alternatives.

I don't think a FAQ entry would have to take the strong view that
dynamic typing is the only way to go.  Certainly that's not the
consensus.  (There's lots of Haskell fans here, for example.)  It
would be all to the good for the FAQ to discuss the language
design trade-offs.

However, I suspect that the question that's actually frequently
asked is something like:

    "I'm used to C/C++/Java, and I rely on the compiler using the
    variable declarations to tell me when I've made a type error or
    mistyped a name.  How can I avoid these kinds of bugs in Python?"

This is not a deep question about language design; it is, as you
aptly observed, a question about development practices.  I think
it would be nearly enough for a FAQ entry to say that Python
programmers mostly rely on automated test suites to detect these
kinds of bugs (and many others besides), to give some description
of the development process that entails (with mention of TDD as
the extreme case), and then to direct the reader to, say, that
article of Bruce Eckel's for some anecdotal evidence.

> I don't see what there is to fear in this regard either. Lisp/Dylan have 
> done optional typing and range checking, and it improves safety as well 
> as performance -- without changing the character of the languages or how 
> they're used. I don't see why Python would be any different.

Sounds fine to me.  Want to write the patch?  :)

  [...]
> > (I don't think "functional programming" means what you think it
> > means.  Functional programming is programming without
> > side-effects.)
>
> Actually, yes, this is what I mean. [...]

My mistake.

> [...] The multiple variable assignment and 
> multiple return values in Python allows for programming without 
> side-effects. [...]

But assignment is the quintessential side-effecty operation, nyet?

-- 
Steven Taschuk                            staschuk at telusplanet.net
Every public frenzy produces legislation purporting to address it.
                                                  (Kinsley's Law)





More information about the Python-list mailing list