type checking

Alex Martelli aleaxit at yahoo.com
Sun Oct 12 06:42:12 EDT 2003


Donn Cave wrote:

> Quoth Stephen Horne <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$.co.uk>:
> ...
> | If you really do need static typing (as opposed to simply needing to
> | get used to the change), Python is simply the wrong choice of
> | language. Either Java, C# or Delphi may be a good option for you.
> 
> Also consider functional languages with strong static typing and
> type inference - Haskell, Clean, ML, Objective CAML.  Even if they
> eventually turn out to be unsuitable for the task at hand, they
> offer an interesting and rigorous abstraction of computer programming.

I'd like to second Donn's recommendation and express reservations
on Stephen's.  Java &c just don't have a high enough semantic level
to give you the same productivity as Python.  The languages Donn
lists *DO* (well, I haven't actually tried out Clean, but it looks to me
as if it does).  O'CAML in particular is multi-paradigm, a bit rambling, and 
perhaps not with the most elegant syntax -- sort of like C++ in these
respects -- but, also like C++ (and Python) takes a LOT of care to
practically FIT IN with your need for solution (e.g. SWIG supports it
to ease interfacing external C=coded libraries).  And the base paradigm
of O'CAML is statically typed (even too strict maybe, if you still have to
write +. instead of just + when you're summing floats...) AND very high
level (functional).  Haskell is even more mind-expanding and much more
elegant, though perhaps its practicality is (sigh) lesser.  Standard ML may
be a bit in-between, perhaps (don't know it as well as the others).

In the end, if you're REALLY keen for static typing you owe it to yourself
to try the real thing, rather than the semi-strict Java &c approaches.  If
you're looking to learn, Haskell is hard to beat; if to get practical 
solutions to problems, O'CAML may be better.  Python is IMHO wonderful
if you DON'T make a fetish of static typing (you might want to try Erlang
for pure functional programming without static typing, btw).

Many of us who used to revere static typing (e.g., Robert Martin, well
noted consultant and author, former editor of C++Report) are on record
as having acknowledged that dynamic typing in fact works better for us.
It just took us a few years to realize this, and vast experience with both
kinds of languages.

If your mind is shaped differently from ours, so that static typing DOES
work better for you even after you've thoroughly familiarized yourself with
a good dynamic-typing language, then moving to a good static-typing
language may indeed be the best strategy for you -- and today's wealth
of choices means no practical restrictions need stop you from doing that.


Alex





More information about the Python-list mailing list