Python in "math through programming" curriculum

Alex Martelli aleaxit at
Wed Dec 20 07:52:53 EST 2000

"Neelakantan Krishnaswami" <neelk at> wrote in message
news:slrn9402bt.fa6.neelk at
> I disagree with you here about Python's appropriateness. Conceptually,
> the strongly typed FPLs are the best languages there are for learning
> about the mathematics of computer programming. The combination of

I wouldn't consider anything but Haskell if I were to teach "the
mathematics of computer programming" (that may be because my
exposure to Clean is too limited) stricto sensu (there's a lot
of math, connected to computer programming -- see all of Knuth's
'Art of Computer Programming' -- that is not the math OF computer
programming... Python, and a RISC machine language, would be good
for _that_!-).

But "math through programming" is a completely different issue,
at least as the original poster meant it (as he explained in a
followup to this post of yours) and as I took it -- middle and
high school levels, as he had said!  I would *NOT* introduce
Haskell in middle school, and even for high school, I have my
doubts -- students would have to have strong *previous* exposure
to mathematical concepts, AND to computer programming; few high
schools, I suspect, are good enough for that.

> > Caml, IMHO, has rather cluttered syntax when compared to Haskell (or
> > Python!); it only gets worse when the Object-oriented extensions are
> > also considered.  Admittedly, a minor consideration, but, _for the
> > specific issue of programming-newbies_, not a negligible one IMHO.
> This is the *big* weakness of the ML-family languages (including
> Haskell and Clean): they all have gnarly syntaxes. Python is proof

Haskell's syntax is *lovely*!  How can you class it in "the ML
family"?  [Again, I don't know enough Clean to have a real opinion
about it].

> that a simple syntax is extremely important; it has essentially the
> same semantics as Perl, yet I would gnaw off my arm to escape
> programming in Perl and quite enjoy programming in Python. Random

Oh, I fully agree on this one.  But, *Haskell*?!

Consider list comprehensions, for example.

In Haskell:

    [(x,y) | x <- [0,1,2], y <- [0,1], x > y]

in Python:

    [(x,y) for x in [0,1,2] for y in [0,1] if x > y]

Sure, Python is using more keywords ('for', 'in', 'if') where
Haskell uses punctuation ('|', '<-', ','), but surely that is
a _very_ surface issue -- and the end result could be argued
either way (I think somebody familiar with common mathematic
notation for sets might well find the Haskell case clearer!).

Python and Haskell also share such syntax elements as the
significance of whitespace ('offsides rule' in Haskell),
which lets one express many things unclutteredly.

What specific objections do you have to Haskell syntax...?


More information about the Python-list mailing list