I’ve used OCaml about ten years ago for fractal rendering (example here) and while I had some issues with it, mostly lack of operator overloading and a somewhat paltry ecosystem, it was mostly a decent experience. I’ve been looking into F# as well but since I think the optimal experience for that is on Windows (which I don’t have installed) even though .NET Core is pretty straightforward, so I’m looking at OCaml again.
I’ve followed the instructions here although updated with the latest version:
Important stuff that stands out already: core (batteries is pretty much dead yeah?), utop, dune, merlin. I have merlin set up with Vim and I believe it works with YCM.
What else is a must have for today’s OCaml developer and what are the best resources for (re-)learning the language? A lot of material I found seems pretty old but maybe the language standard is just quite stable.
From what I understand Batteries has been releasing steadily. There is also the Containers library which is highly regarded. And the dark horse in the race … the OCaml standard library, i.e. Stdlib. It has been steadily getting more more fleshed-out after being renamed from Pervasives and rearranged a bit. I would even go as far as to say that it’s a must-have for today’s OCaml developer
VS Code with the OCaml Platform plugin paired with the OCaml LSP server is what I would suggest even though vim + merlin is a powerful combo. You might also want to checkout Real World OCaml. Just in case you’re not familiar Opam is great for managing the compiler installation as well as any libraries you’re using.
Batteries is stable and continues to be maintained with regular releases. Like many mature projects, development has slowed and they certainly would welcome more contributors. @UnixJunkie just did a presentation last month on Batteries at the Houston Functional Programming User Group, which included a comparison of the advantages and disadvantages of OCaml’s various alternative stdlibs. Slides from his presentation are at https://hfpug.org/2021/01/21/francois-berenger-ocaml-batteries-included/
I can recommend tuareg-mode in emacs (I use doom-emacs with vim bindings) for a lovely IDE experience (bonus points for steering clear of Microsoft’s growing monopoly on dev tooling).
Expect testing (using ppx_expect, included in ppx_jane) and the cram-style testing supported by mdx and dune are really lovely, and afaik pretty unique the ocaml ecosystem? Inline testing is also nice (via ppx_inline_tests).
Some of the best learning resources I’ve enjoyed (aside from simply reading the language reference) have been from years- or decades-old works.
I think Xavier linked to this recently somewhere on this forum, but here is a paper describing how a team recovered the sources for and reproduced results from a notable parallel programming system implemented in OCaml, targeting v1.07, originally released some 20+ years ago: https://hal.archives-ouvertes.fr/hal-02885664
A relevant quote:
To our great surprise, and satisfaction, the code compiled with the modern OCaml 4.05 installed on our machines unchanged. The only notable difference is that the modern compiler produces several new warnings that correspond to better static analysis checks introduced over the past quarter of a century.
ocp-indent is nice but I’ve come to prefer ocamlformat even though I don’t necessarily agree with the defaults. I personally prefer a more vertical style as it allows for better diffing, something along the lines of:
I use Vim with Ocaml LSP server and ocamlformat and it was surprisingly easy to set up. One annoyance is that I have to run dune build in the terminal if I want to propagate module changes across files.