4 ms·
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
by haberman 15y ago
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.
- cageface 15y agoThe 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.
- getsat 15y agoThe monad in question: http://en.wikipedia.org/wiki/Haskell_features#ST_monad http://en.wikipedia.org/wiki/Haskell_features#ST_monad
- Drbble 15y agoSort of. It is more like every function in OCaml is in IO. There is just no purity guarantee anywhere.
- Hemospectrum 15y agoI 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/marktoberdorf/ http://research.microsoft.com/en-us/um/people/simonpj/Papers...).
- carterschonwald 15y agoBoth 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)
- carterschonwald 15y agoBoth 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)
- SkyMarshal 15y agoI'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).
- gtani 15y agoBesides 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://news.ycombinator.com/item?id=2725100 http://www.quora.com/What-are-the-key-differences-between-Haskell-and-Standard-ML http://www.quora.com/What-are-the-key-differences-between-Ha... http://stackoverflow.com/questions/5600246/sml-conversions-to-haskell http://stackoverflow.com/questions/5600246/sml-conversions-t... http://www.cs.washington.edu/education/courses/cse505/98au/slides/slides.10-26.ps 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 http://news.ycombinator.com/item?id=3481700
- gregwebs 15y agonot 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.
- haberman 15y agoIs there something about Haskell-the-language that offers concurrency/parallelism benefits or is this primarily an advantage of GHC-the-implementation?