dynamic typing question

Hung Jung Lu hungjunglu at yahoo.com
Fri Dec 26 21:27:29 CET 2003


claird at lairds.com (Cameron Laird) wrote in message news:<vuojf5kc3v1lca at corp.supernews.com>...
> 1.  Why, in your mind or your teammate's,   
>     is dynamic typing a "lack"?  What, pre-       
>     cisely, is the benefit of static typing?       
>     There are a number of legitimate 
>     answers.  It occurs to me that, without 
>     precision on which interest you, we 
>     might be missing an opportunity to 
>     clarify "The Python Way" significantly.

One static typing advantage I've run into:

When you change the name of a variable in a class, and re-compile the
program, the compiler shows you ALL places where compilation fails.
These could be hundreds of places in dozens of files. In dynamically
typed language like Python, you have to rely on text search, which
often yields many false positives, especially for common/overloaded
names like .count, .name, .type, etc. In statically-typed languages,
making name changes is not very painful, since the compiler will tell
you where exactly you need to follow up with the changes. In
dynamically typed language, you will have to manually write unit test
codes to ensure name consistency.

I am sure Python people have come up with strategies to deal with this
problem. That's what I'd like to hear. (Unit test is one route.) But
this is one place where I've found statically-typed compilers useful.
I mean, I have seen this discussion many times, but most responses
from Python users have not been realistic (often simply shrugging off
the problem and saying something like "compilers don't detect all the
bugs, blah blah blah".) I would like to hear more real-life experience
rather than academic conjectures.

regards,

Hung Jung




More information about the Python-list mailing list