Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a primarily imperative programmer who is just becoming more familiar with Haskell, I'd love to see a compare/contrast between Haskell and Ocaml from someone with expertise in this area.


The biggest differences are that Haskell defaults to lazy evaluation and OCaml defaults to strict and that OCaml allows you to mix in imperative code without explicitly using constructs like monads.


I think modules vs. typeclasses are a bigger difference. The Haskell approach to IO isolation would be much more horrible without exploiting features peculiar to the typeclass system. The IO system in early versions of Haskell did not exploit these features, and it was a disaster (http://research.microsoft.com/en-us/um/people/simonpj/Papers...).



Sort of. It is more like every function in OCaml is in IO. There is just no purity guarantee anywhere.


I'm not well versed on Ocaml, but my impression is that the biggest conceptual difference is that Ocaml is more lenient with side effects. Haskell restricts any code with side effects like IO to Monads, whereas Ocaml allows IO, mutable data, etc. It may be possible to write Ocaml like Haskell, and manually restrict side effects to Monads, I'm not sure, but in Haskell you have no choice.

There are other differences as well, but imho that one sets Haskell apart moreso than any of the others, and not just from Ocaml but from every other language (that I know of at least).


Both are great, both have their strengths and weaknesses. Start with whichever you feel comfortable with, and branch out to the other when you want to discover a new dimension. Ocaml has a lot of strong points and a statically typed module system, Haskell has a less restrictive type system and a different way of dealing with heterogeneous polymorphism, and has all the good / bad that come with laziness by default (mostly good, with a dash of gotchas)


Besides laziness/immutability, the HN modules vs type class debates (there's also Lambda-ultimate debates, but they take that stuff so seriously

http://news.ycombinator.com/item?id=2725100

http://www.quora.com/What-are-the-key-differences-between-Ha...

http://stackoverflow.com/questions/5600246/sml-conversions-t...

http://www.cs.washington.edu/education/courses/cse505/98au/s...

(yes, from 1998, but worth the PS conversion if youre on windows)

http://news.ycombinator.com/item?id=3481700


not mentioned by others is the real reason why Haskell is winning: concurrency & parallelism. The GHC compiler for Haskell has an incredible runtime with async IO by default, it is capable of running millions of threads, works on multi-core, and has a good STM implementation.


Is there something about Haskell-the-language that offers concurrency/parallelism benefits or is this primarily an advantage of GHC-the-implementation?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: