[Haskell-cafe] Rethinking OO idioms
John Goerzen
jgoerzen at complete.org
Thu Sep 30 09:21:19 EDT 2004
On Thursday 30 September 2004 07:54 am, Jeremy Jones wrote:
> John (and Haskell community),
>
> I just subscribed to the Haskell mailing list the other day and this
> posting grabbed my attention. I've been workin with Python for a few
> years now and have recently decided to try to expand my horizons to
> Haskell (and OCaml). I love Python, but I feel like I could learn a
> lot that could be applied to Python from understanding FP languages
> like Haskell (and OCaml). That being said, can you point me to any
One of the interesting things about Python is that it has slowly been
adding functional programming mechanisms to the language. Some of the
constructs we all love in FP are available on Python. For instance:
* anonymous functions ("lambda" keyword)
* nested scopes and the ability to return functions
* iterable objects
On the other hand, Python's typing system is nowhere near as powerful as
that of Haskell or OCaml. OCaml, and to an even larger extent,
Haskell, have a wonderful typing system: it's strong, yet it
inobtrusive. I am a fan of that, and it helps these languages scale to
large projects better than Python -- while at the same time keeping
them suitable for small ones (unlike, say, Java)
OCaml has an object system. It's not as powerful as Python's in most
respects, and can be loosely described as a functional hybrid of the
Python and Java object systems <grin>
I find myself writing most of my new code in OCaml these days. If I can
manage to get a Haskell compiler built on AIX, I may move to
Haskell :-)
(Building anything on that platform is difficult, sigh)
> documentation online or books that are more suited to a Python person
> trying to understand Haskell (and OCaml)? Any help is appreciated.
This is a great resource: Learning OCaml for C, C++, Perl, and Java
programmers:
http://www.merjis.com/developers/ocaml_tutorial/
I wish something like that existed for Haskell. I may write one
someday. :-)
Once you know OCaml, though, Haskell will come a lot easier. The typing
systems are quite similar, as are many of the concepts. I/O is very
different though. Haskell I/O is different from anything else I've
ever seen, so I can't really come up with a good analogy for you
there :-)
This is a good Haskell tutorial: http://www.isi.edu/~hdaume/htut/
More information about the Haskell-Cafe
mailing list