Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Haskell vs OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-08-14 (13:28)
From: Peng Zang <peng.zang@g...>
Subject: Re: [Caml-list] Haskell vs OCaml
Hash: SHA1

On Thursday 14 August 2008 07:50:43 am blue storm wrote:
> The main differences are :
> OCaml is impure (imperative features in the language), Haskell is pure.
> OCaml is strict, Haskell is lazy.
> Ocaml has modules, Haskell has type classes.

I would restate the last as:

  OCaml has an object system, Haskell has type classes.

In Haskell you can write a function that takes anything that is "showable" (a 
type class) and print it out.  The sig would be something like (I'm mixing 
OCaml and Haskell syntax here, but hopefully the point is still clear):

  Showable 'a => 'a -> unit

You can't quite do that with modules/functors.  However with objects you can 
write a function that takes a showable and executes it.  It's sig would look 
like this:

  showable -> unit


  class type showable = object
    method print : unit -> unit

As to Haskell vs. OCaml, they are both great languages.  Haskell is more 
researchy and experimental (although with Haskell Prime they are making a big 
push to make it more friendly to industrial uses).  This is great because you 
get some really cool stuff.  This is also bad because all the cool stuff is 
hard to understand and sometimes you-just-want-to-get-stuff-done.  OCaml is 
great for that and for one other thing that I think few people point out.  
OCaml supports a variety of programming styles: OO, imperative and 
functional.  This means it's easy for anyone to pick up and use.  If you have 
collaborators, OCaml projects have an easier learning curve.  Anyone can feel 
more or less at home using OCaml in a week.  In contrast, Haskell has quite a 
steep initial learning curve (eg. you need to learn monads before you can 
write any interesting real-world application) which can be a big barrier to 
potential collaborators.

Also the ability to switch styles often lets you write faster.  For some 
problems, I just think in one style versus another.  It just comes more 
easily to me in a functional style sometimes, and an OO style other times.  
OCaml let's you write however you think about it.  Haskell makes you think 
about it in *the haskell* way.  Sometimes this is good because it forces you 
to do certain things.  Othertimes it just gets in your way.

Version: GnuPG v2.0.7 (GNU/Linux)