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/
No, batteries is not dead. It is actively maintained:
We might even name the next release “phenix”.
Because the phenix never dies.
ocp-browser and ocp-indent are cool too.
opam is a must have, as mentioned by others.
what you definitively need, are some stickers on you laptop lid or office door.
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: [Rp] Reproducing and replicating the OCamlP3l experiment - Archive ouverte HAL
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.
So, enjoy those older reference materials.
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:
break-cases = fit-or-vertical
break-infix = fit-or-vertical
break-fun-decl = fit-or-vertical
type-decl = sparse
I think you mean “phoenix”.
In french we write “phénix”, or in old style “phœnix”.
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.
@readyready15728 it could be helpful to take a look at Ocamlverse.