points by pdimitar 5 years ago

(EDIT: I misread your question, apologies. OCaml vs. C++ is mostly because of much less surprises to start working with it. OCaml vs. Rust is mostly because Rust mandates you to pay attention to a lot more initially (`Result`-s being a prominent example, although using `.expect()` or `.unwrap()` actually helps a lot) and even if I absolutely love that you have to iron-proof your code, it does get in your way when you just want to try something quickly. It kills the motivation intrinsic to the flow state.)

---

(Original reply:)

I'll admit it's not a factual and clear-and-cut distinction.

OCaml has warts (no multicore, although that's claimed to be very close to complete now; also no UTF-8 strings by default, and a somewhat surprising tooling, the first time at least) but I found Haskell to ask too much of me to even start -- I almost immediately grokked monads and lazy evaluation but it seemed to be too much effort for something you'd like to quickly play with. And when I saw the list of all compiler variants I almost gave up right there and then.

OCaml, as mentioned in the parentheses above, isn't without problems too but I found that I could get to a working dev stack and the ability to make a quick program and run it, much quicker compared to Haskell. Also, it's very terse.

Not the most compelling or factual of reasons but this is how I arrived at that place where I prefer OCaml for sketching ideas and not Haskell.

eru 5 years ago

OCaml is a much smaller language than Haskell.

Similarly, Erlang (and thus Elixir, I guess) is also comparatively small and simple.

Surprisingly, C would be in the same category, if it wasn't so primitive and likely to make you shoot yourself in the foot.

I've programmed professionally in both OCaml and Haskell (and Erlang and C etc). I find that Haskell is generally more terse than OCaml.

They are both fine languages. Subjectively, Haskell feels a bit more fun to me. But if you want to really get into it, it helps to have some people around who know what they are doing.

  • pdimitar 5 years ago

    Interesting how different experiences with the same thing can be! :)

    > it helps to have some people around who know what they are doing

    I think that's the crux of my issue. OCaml wasn't the easiest to start with either but it took me 2-3 casual evening sessions to just be able to sketch code and run it immediately with almost no hassle.

    But yeah, can't deny Haskell kind of rubbed me the wrong way so I am likely biased now.

    • eru 5 years ago

      It does feel fun to bust out a few Project Euler challenges with OCaml; and as a reasonable experience programmer you should be able to do that after those 2-3 casual evening sessions.

      It's been a few years since I last did OCaml. At that point, the ecosystem was a bit more mature for Haskell. More libraries, better editor support, etc.

      In some platonic sense I like small languages, but I had come to appreciated all the extra comfort Haskell provides. OCaml was just too much in the uncanny valley of being almost Haskell, but then missing some nice-to-haves. I might grumble, but OCaml is a pure pleasure compared to C++.

      Btw, they finally added (optional) stacktraces to Haskell a few years ago.

      About all the language extensions in Haskell: I like them, but they can be overwhelming. Luckily, the language extensions your libraries use has almost never any bearing on what language extensions your client code uses.

      So you can ignore the extensions, and still use your favourite libraries.

      • garethrowlands 5 years ago

        Seems likely Haskell will get stack traces by default fairly soon.

        • eru 5 years ago

          GHC already gives you stacktraces when you compile with profiling on. You say they are going to turn them on by default? Interesting!

jnxx 5 years ago

Many thanks for the explanation!