Is Python your only programming language?

Brandon Michael Moore brandon at its.caltech.edu
Thu Aug 14 14:27:36 EDT 2003


On 14 Aug 2003, Nick Vargish wrote:

> Tim Rowe <tim at remove_if_not_spam.digitig.co.uk> writes:
>
> > If I want to get something up and running quickly then I go straight
> > to Python.  If thousands of lives depend on the code working right I
> > would not be allowed to use Python, and, IMHO, quite rightly too.  It
> > just doesn't have what it needs for proving correctness, and adding
> > those things would scupper the getting things up and running
> > quickly.
>
> So what programming language actually does bridge the gap between
> "thousands of lives depend on the code working right" and "getting
> this up and running quickly"?
>
> Whenever someone implies that compile-time type checking provides some
> "proof of correctness", I think about (void *) and am not very
> convinced.
>
> Nick

Sure, type checking with a sorry excuse for a type system like C provides
doesn't buy you that much. Take a look at Haskell (espcially the GHC type
system extensions). In the functional programming community people say "if
it type checks it usually works", and Haskell's type system is stronger
than most. It's probably worth pointing out that strong typing doesn't
mean you need to fill your program with types like C. Most of the types in
a Haskell program are inferred. You can say things like "takes any object
that can be converted to a string". If you are sufficiently perverse you
can even given an append operation a type that reflects the length of the
lists. Referential transparency makes it much easier to prove the
correctness of functions in isolation, which isn't really the type system,
but does help write correct code.

For rapid development lazy evaluation and the IO system (monads) make it
really easy to define and combine abstractions. You can take "once and
only once" a lot farther than in most languages. There are a few
weaknesses though. Performance isn't as good as you might expect from a
compiled language (you can always write C though). Library support is a
bit weak for things like data base interfaces and GUIs. There are
interesting GUI and database libraries, but nothing really mature.

Actually, I think python with a litte bit of type checking would be safer
than C++ or Java. C++ has explict memory management, which can be a pain
to debug, and Java has no templates so any generic functions lead to code
littered with unsafe downcasts. Python does garbage collection, and a
program checker can use any type system it wants. Probably 99% of python
code could be given types like "takes objects with these methods", etc.
The smartest tool I know of is PyChecker which doesn't sound like it does
more type checking that counting arguments. I just heard about it today
though, so I'm probably wrong.

Brandon







More information about the Python-list mailing list