Python from Wise Guy's Viewpoint
Pascal Costanza
costanza at web.de
Thu Oct 23 04:33:53 EDT 2003
Marshall Spight wrote:
> "Pascal Costanza" <costanza at web.de> wrote in message news:bn774d$qj3$1 at newsreader2.netcologne.de...
>
>>>When do programmers know better? An int is an int and a string is a
>>>string, and nary the twain shall be treated the same. I would rather
>>>``1 + "bar"'' signal an error at compile time than at run time.
>>
>>Such code would easily be caught very soon in your unit tests.
>
>
> Provided you think to write such a test, and expend the effort
> to do so. Contrast to what happens in a statically typed language,
> where this is done for you automatically.
There are other things that are done automatically for me in dynamically
typed languages that I care more about than such static checks. I don't
recall ever writing 1 + "bar". (Yes, this is a rhetorical statement. ;)
> Unit tests are great; I heartily endorse them. But they *cannot*
> do everything that static type checking can do. Likewise,
> static type checking *cannot* do everything unit testing
> can do.
Right.
> So again I ask, why is it either/or? Why not both? I've had
> *great* success building systems with comprehensive unit
> test suites in statically typed languages. The unit tests catch
> some bugs, and the static type checking catches other bugs.
That's great for you, and if it works for you, just keep it up.
But I have given reasons why one would not want to have static type
checking by default. All I am trying to say is that this depends on the
context. Static type systems are definitely not _generally_ better than
dynamic type systems.
Pascal
More information about the Python-list
mailing list