does lack of type declarations make Python unsafe?

John Roth johnroth at ameritech.net
Wed Jul 2 14:21:35 EDT 2003


"Aaron Watters" <aaron at reportlab.com> wrote in message
news:9a6d7d9d.0307020959.634ceb4e at posting.google.com...
> David Abrahams <dave at boost-consulting.com> wrote in message
news:<usmq86vit.fsf at boost-consulting.com>...
> > Duncan Booth <duncan at NOSPAMrcp.co.uk> writes:
> >
> > I'm not saying that Python isn't a wonderful language -- it is.
It's
> > great to have the flexibility of fully dynamic typing available.
All
> > the same, I'm not going to pretend that static typing doesn't have
> > real advantages.  I seriously believe that it's better most of the
> > time, because it helps catch mistakes earlier, makes even simple
code
> > easier to maintain, and makes complex code easier to write.  I would
> > trade some convenience for these other strengths.  Although it's
very
> > popular around here to say that research has shown static typing
> > doesn't help, I've never seen that research, and my personal
> > experience contradicts the claim anyway.
>
> I'm somewhere on the fence.  I've seen static typing catch errors,
> but I've also seen static typing (in java, say) make the use of a
> hash table into an exercise in code obfuscation.  I'd really like some
> sort of compromise where you could harden types incrementally.  Also
> static typing can make it more difficult for bad programmers to do
> stupid things...
>
> I'd like to see research either way.  I've heard of rumored research
> in both directions.  Personally, I suspect the widely repeated
statement
> "90% of programming errors are typing errors" can be traced back to
the
> 60's when engineers wrote programs on graph paper-like sheets and
> handed them to TYPISTS who then TYPED THEM WRONG onto punch cards.

Keypunch operators. Not typists. Please...
(Been there, done that. The '50s and '60s hacker's motto:
"Sequence numbers are for sissys."

I think you've pretty much got my attitude toward static typing down:
I think it's an oversimplified reaction to a rather real problem.

Notice that 2.2 does several things that static typing claims to do for
you:
Slots makes it impossible to mistype an instance variable name, and
property descriptors allow you to put in whatever amount of type
checking you want on instance bind operations.

John Roth
>
>   -- Aaron Watters
>
> "You mean life is not a fountain???"






More information about the Python-list mailing list