Python from Wise Guy's Viewpoint

Fergus Henderson fjh at cs.mu.oz.au
Wed Oct 22 20:38:50 EDT 2003


Pascal Costanza <costanza at web.de> writes:

>Marshall Spight wrote:
>> But why should more regression testing mean less static type checking?
>> Both are useful. Both catch bugs. Why ditch one for the other?
>
>...because static type systems work by reducing the expressive power of 
>a language. It can't be any different for a strict static type system. 
>You can't solve the halting problem in a general-purpose language.

Most modern "statically typed" languages (e.g. Mercury, Glasgow Haskell,
OCaml, C++, Java, C#, etc.) aren't *strictly* statically typed anyway. 
They generally have some support for *optional* dynamic typing.

This is IMHO a good trade-off.  Most of the time, you want static typing;
it helps in the design process, with documentation, error checking, and
efficiency.  Sometimes you need a bit more flexibility than the
static type system allows, and then in those few cases, you can make use
of dynamic typing ("univ" in Mercury, "Dynamic" in ghc,
"System.Object" in C#, etc.).  The need to do this is not uncommon
in languages like C# and Java that don't support parametric polymorphism,
but pretty rare in languages that do.

>I think soft typing is a good compromise, because it is a mere add-on to 
>an otherwise dynamically typed language, and it allows programmers to 
>override the decisions of the static type system when they know better.

Soft typing systems give you dynamic typing unless you explicitly ask
for static typing.  That is the wrong default, IMHO.  It works much
better to add dynamic typing to a statically typed language than the
other way around.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.




More information about the Python-list mailing list