i continue to be mystified by people who start learning Haskell, an explicitly functional programming language, and immediately try to write OO code in it. i'm not talking about the typical confusion of Haskell typeclasses with OO classes (Haskell's typeclasses are more like Java's interfaces), which is understandable. i'm talking about things like this quote from a post to the Haskell-café list:
So i have to wonder, given that this person doesn't seem to want to leave the OO paradigm, whether OCaml, which has a type system broadly similar to Haskell's, might be a better choice?
1. This was actually said by Charles Babbage, regarding his difference engine:
After many years of OOP though my brain is wired up to construct software in that 'pattern'....a problem for me at the moment is I cannot see how to construct programs in an OO style in Haskell....I know this is probably not the way to approach it...but I feel I need to master the syntax before the paradigm.As has been said in another context,
I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a [comment]1. To use an old cliché, it seems to me to be a bit like trying to bang in a screw with a screwdriver as though it's a hammer. i mean, trying to understand the syntax? Fair enough, although understanding Haskell's syntax is probably not that difficult in comparison to, say, learning its type system. But trying to understand it by trying to implement OO in an explicitly functional - not functional-oriented, like Scheme, or multi-paradigm, like Common Lisp - language? Isn't that trying to run before one can crawl? The poster in question says that he's primarily interested in Haskell's type system - and it is indeed rather nifty, as least from my perspective as a noob to type systems - but i don't see how one can learn about that system without also having to deal with the fact that Haskell is a functional language with non-strict semantics. For example: in learning about the
IO () type, one has to learn about how Haskell uses monads to 'quarantine' side-effect-producing IO from side-effect-free code; and not only that, but there's a good chance that one is going to get bitten by the laziness of hGetContents.So i have to wonder, given that this person doesn't seem to want to leave the OO paradigm, whether OCaml, which has a type system broadly similar to Haskell's, might be a better choice?
1. This was actually said by Charles Babbage, regarding his difference engine:
On two occasions I have been asked, – "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" In one case a member of the Upper, and in the other a member of the Lower, House put this question. I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.