Hi! I’m Christine, a technical writer at Tarides.
I’d love to hear from the community on this topic. One of the misconceptions about OCaml is that there aren’t enough libraries. I’d like to write a blog article dispelling this myth for newcomers to OCaml or programmers who might want to try OCaml.
What are your top 5 favorite OCaml libraries and why?
Most used: stdlib, lwt, cmdliner, ounit, cohttp
Other libraries I’ve enjoyed using: ocamlgraph, angstrom, zarith, cryptokit, yojson
Sorry, but the “why” is really difficult to describe - it’s a mix of many reasons - the type of stuff I happened to work on, the utility of these packages, the available alternatives, the nice abstractions and design-choices, the reliability/quality, how well they’re documented etc.
I think each library could probably have its own blog post about the pros/cons, written by someone more articulate, but I wanted to offer my list, even without anything useful in terms of “reasons why”.
It also has functionality for running asynchronous code in parallel.
I don’t think that’s entirely correct. Lwt helps with creating concurrently running code, we’ll have to wait for OCaml 5 to get parallel programming facilities.
Thank you for writing this article! I like your choices and I’d add:
The last two are my personal choice for an improved standard library and async support, but as others mentioned, there’s several options in this space:
This is all good stuff! Thank you for sharing these and why you like them. All of these from all of you will help with my future article, and they will help newcomers understand there are lots of libraries for OCaml!
bos (and fpath) to interact with os/filesystem (recently)
cmdliner for cli interfaces (well documented even though I often need very small reminders and look at the cheatsheet instead)
containers my goto stdlib extension, I like that is comprehensive, well documented and just extend the stdlib, so I introduce it only if I need and things don’t break
cohttp it is straightforward and always worked well for my needs
My GOTOs that show up in every project for which I can choose libraries:
base: for the comfort of having well designed and homogeneous APIs for List/Option/Seq/Hashtbl/Map/etc
(dune’s) pp: very pleasant replacement for Format that is still compatible with it (Pp.to_fmt) → for people who have better things to do than hunting for opening and closing boxes
Bünzli’s ptime/(ez)jsonm/xmlm/cmdliner → reliable, well documented
increasingly fond of the JaneSt’s PPXs: sexp, variants, fields, equal, compare, and especially ppx_expect
Most of them are about reducing the mental load for dealing with the basics and saving brain power for real & interesting problems.
First, gsl (ocaml-gsl oandrieu and M. Mottl) because I am a numerical physicist, on the analysis side (integration, differential equations, etc).
The GSL (Gnu Scientific Library) is a C library for numerical calculations.
This may be not said very often but OCaml is great for numerical physics ! I switch to OCaml 20 years ago thanks to the existence of ocaml-gsl. I was using the GSL in C/Fortran and the OCaml wrapper is great to insure the correctness of the algorithm, for the readibility, etc. For example, in analysis basically everything is a float and OCaml allow to distinguish between them.
Wow, I am really positively surprised, how many people are using OCaml for scientific/engineering applications (when looking at libs like owl, gsl, lacaml & python interop).
They’re well designed, and rarely leave me feeling like they lack something useful. On the contrary, I feel like I keep finding new useful stuff in them all the time.
More recently, I’ve been playing around with incremental, which has been really nice. It’s super powerful (like excel on steroids), and I love how seamless it is to get it working on the browser.
ppx_expect and quickcheck are pretty great, and recently I’ve also started using tezt more, which is pretty nice for its CI integration (auto balancing tests, and creating JUnit reports).
Edit: wanted to add esy to the mix. It’s a bit rough around the edges but when it works, it’s rock solid and super simple.
Thank you so much for chiming in with your favorite libraries and why, @arno, @kkirstein, and @rdavison!
@kkirstein, I’ll also be writing a few posts on dispelling some common OCaml misconceptions, and one of them is that it’s mainly for academic use. Great that people are using it for scientific/engineering. Perhaps I’ll make a new Discuss post asking what cool projects engineers are using OCaml to make.