Re:Real World Ocaml announced
by haberman on Monday February 27, 2012 @10:20PM
(#3641733)
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.
[ Parent
| on HN ]
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.
Re:Real World Ocaml announced
by Hemospectrum on Tuesday February 28, 2012 @02:20PM
(#3644484)
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...).
The monad in question: http://en.wikipedia.org/wiki/Haskell_features#ST_monad
Sort of. It is more like every function in OCaml is in IO. There is just no purity guarantee anywhere.
Re:Real World Ocaml announced
by SkyMarshal on Tuesday February 28, 2012 @12:15AM
(#3641997)
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).
Re:Real World Ocaml announced
by carterschonwald on Monday February 27, 2012 @11:22PM
(#3641872)
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)
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.