not safe at all

Dennis Roark denro at earthlink.net
Sat Jul 14 16:00:25 EDT 2001


Had no intent in starting such a burning war over the issue
of typing.  It does show how deeply held is the approval for
Python among the newsgroup readers.  I love it also, and as
one of the responders said, it is  "more fun" to program in
Python than in other languages of my experience.  But this
will be an individual issue.

I think we should try to keep personal insults out of what
should be a discussion of ideas.  I am offended by
Christopher's assertion of lacking skill or not being smart
enough to use dynamic typing, binding, and yes I did know
what that meant before my original note.  Had I not been
smart enough to see the dynamic typing, then I don't think I
could have made up my original example that started all
this.  

I do know C++ (and Delphi, and VB -- ugh) much better than I
know Python.  I have some familiarity with LISP and small
talk.  I like the generics of other OO languages and the
templates of C++, which is part of the reason I am not a big
fan of Java.  But why insult me now that I am expanding my
base into Python?

Dynamic typing, or binding, reference variables that can
change the type pointed to, are to me still part of a weaker
type safety than if they were not there.  That is a personal
preference, that is all.   So let's hold back the ad hominem
attacks and help each other progress.  There is no perfect
language, and all of the "good" languages have appropriate
use.  That includes both Python and C++.  Not all
programmers will ever agree what the appropriate use of a
particular language should be.

I understand Christian Tanzer's distinction between strong
and weak typing and static verses dynamic type binding.  And
one of the things I and probably most C++ programmers like
about C++ is that you can relax the typing by explicit
casting.  (The compiler should at least give warnings for
implicit casts.  And a cast of an instance of a user defined
class is only permitted if the the class author wrote the
corresponding copy constructor.)  But that you must
explicitly cast means that you know and can limit where you
relax type safety.

As far as forcing variable declarations are concerned, as to
their names and types, yes it may be regarded as a "feature,
not a bug" that Python does not have this.  But I recall the
evolution of a language that for other reasons I really do
not like, Visual Basic.  Originally, there was not a way to
force declaration of variables.  It was programmer pressure
that forced MS to introduce the "option explicit" code
directive which requires declaration.  You can declare, and
not type a variable (in which case it is a "variant") but to
do so is often though to be sloppy coding.   I am not
standing up for VB which has too many annoying features,
including inconsistent syntax, and a very broken object
model.

Along with the group, "Long live Python" but if someone
mentions something they find weaker in Python, long live
them too.

--- Dennis

Christopher L Spencer <clspence at one.net> wrote:

>I often have to do this:
>x=getsomestringfromparameterfile()
>x=string(x)
>
>	I consider this to be an advantage of Python.  If you are not
>skilled enough to use this feature, then I'd suggest you stick with
>Pascal.
>
>Chris.
>
>On Fri, 13 Jul 2001 07:32:28 GMT, Dennis Roark <denro at earthlink.net>
>wrote:
>
>>For amusement, run this little script which demonstrates a
>>near ultimate in the lack of type safety in the language.
>>(Perhaps there is a bit of type safety in that you can't do
>>this:  4 + "one") But look at what you can do in the
>>following script:
>>
>>x = 3
>>x = x + 2
>>print "x =", x
>>x = "now I'm a string"
>>print x
>>x = [ 5, x ]
>>print "and now a list:", x
>>

---------------------------------
Dennis Roark
Dept. of Computer Science
University of Sioux Falls

Starting Points:  http://home.earthlink.net/~denro
---------------------------------



More information about the Python-list mailing list