dynamic typing questions

Shalabh Chaturvedi shalabh at gameboard.org
Fri Dec 19 20:27:15 EST 2003


Jason Tesser wrote (relevant excerpts only):

> We are considering useing Java or
> Python.

> The other programmer here is very concerned about
> dynamic typing though in Python.  He feels like this
> would be too much of a hinderance on us and too easy
> for us to make a mistake and not catch it until
> runtime making debugging harder.
> 
> OK what are your guys thoughts here?  How have you all
> overcome the lack of static typing?

IMHO, the impediments introduced by static typing are not worth the benefit
of catching type errors at compile time. Further, you still have to do
testing to find other bugs.

The increased productivity due to dynamic typing in Python allows for more
testing time to catch _all_ errors (type or otherwise). Development +
testing time for a Python program usually turns out to be much less than
just development time for an equivalent Java program (for me, at least). An
interesting read is Guido van Rossum's interview at 
http://artima.com/intv/strongweak.html

Also note that even in Java, static typing does not achieve much in many
cases (except requiring more keyboard typing), as illustrated in the
following example:

  // myVector is a java.util.Vector, index is an int

  String myStr = (String) myVector.get(index);

If the object in the vector is not a String, it is only at run time that the
error will be caught.

Admittedly, static typing allows the compiler to produce faster programs.
But the question isn't if it is fast. The question is if it is fast enough.

--
Shalabh




More information about the Python-list mailing list