Hacker News new | ask | show | jobs
by klibertp 2907 days ago
It has 3 (4?) different, not very compatible stdlibs, for example. Also 3 tools for syntactic extension, two of which suck incredibly, while the last one is pretty new. It has 2 (3 if you count Reason) very different syntaxes defined, even though I've never seen the "light" kind in the wild. The whole String mutability story is interesting in its own right. I'm sure there's a lot more.

But note: every single language has warts like this, especially if it's been developed for a couple of years already. I think OCaml has probably fewer warts than JavaScript, or PHP, or even Java; but more than Go, or Elixir, or Scheme. It's still very nice language and toolchain, though, perfectly usable in many cases - the learning curve may be steep at some points, but on average it's not that hard to learn, and you gain a lot of benefits if you do.

2 comments

OCaml isn't without its warts (like any language), but I don't quite think you've nailed them.

For one, the different stdlibs are in fact highly compatible. Basic types (option, result, string, int, array, float) are all the same, so code using different stdlibs works together seamlessly most of the time.

Lwt and Async are a different story, and there is a real incompatibility problem there.

The syntax extension story is pretty clear and simple: PPX rules the roost, and the tools for building PPXs are quickly getting better and more unified. Reason is an interesting variant in the ecosystem, but its existence doesn't amount to a wart in my eyes. It's an alternative syntax that you can use interoperably with the rest of the OCaml ecosystem (and Dune makes that awfully easy.)

Some clarifications:

It has one standard library, and several alternative standard libraries of varying popularity. I would argue that Core is probably the most popular. For what it's worth, Haskell also has several replacement for its standard library, Prelude.

For the syntax extensions, the community has largely migrated to PPX. Alternatives are being phased out.

String is no longer mutable in recent versions of OCaml. The string type is now immutable, and a new type, bytes, has been introduced which is mutable.