Typing system vs. Java

Jonathan Hogg jonathan at onegoodidea.com
Tue Jul 31 03:34:33 EDT 2001

In article <mailman.996524288.7635.python-list at python.org>,
 <brueckd at tbye.com> wrote:

> Others on here have pointed out that using C++/Java as an example of a
> strongly-typed language is a mistake, so maybe my opinion is closer to
> "the typing systems in C++ and Java tend to cause me more work and
> problems" and not strong, static typing.

Bingo. This is Java's fault for not having parametric polymorphism 
rather than a problem with strong static typing per se. In my opinion 
it's unfair to lump C++ in with Java since C++ at least has templates to 
do this sort of thing.

Maybe I just haven't been writing large enough programs in Python, but I 
don't feel that I hit many errors where I think "damn! I wish the 
compiler had picked this up for me". I'd be interested in other people's 
opinion on this. (And I've programmed plenty in Haskell so I know a 
strong static typing system when I see one.)

I can though, think of plenty of places where strong static typing would 
defeat intentional exploitation of the dynamic typing. Maybe this is 
poor programming on my part, but I can't even think how one would type a 
function like say:

   def f(zs): return reduce( lambda x, y: x + y, zs )

Python's dynamic typing has the most optimal type for this function:

   "A function that takes something looking like a sequence of
    things that you can call "+" on, and returns something that
    you might get back by "+"ing a bunch of such things together."

I just don't ever see Python with a static type system. What's more I 
don't think I'd want it. If you want static types then code in something 
else. If you find Java/C++ too horrific, then I'd seriously recommend 
O'Caml - though this is just from a cursory look, I did most of my FP in 
Haskell but I don't think I could recommend it unless you're willing to 
become a serious FP-head and want to get to grips with Monads ;-)


More information about the Python-list mailing list