I wanted to ask all of you to share your thoughts on what are the killer use-cases for OCaml today (think along the lines of Rails for Ruby, systems programming for Rust, data science for Python, etc). Basically I want us to discuss the type of problems for which OCaml is a great fit and the tools (e.g. libraries, frameworks, etc) that go hand-in-hand with the respective problem spaces. E.g. one can say that OCaml is a great option for building parsers because of Menhir and so on.
In a way the topic is similar to the recent topic about favorite libraries (see Top 5 Favorite OCaml Libraries? - #17 by arno), but Iâve noticed most people there mentioned just basic libraries, which donât really help to understand how are they actually using OCaml and what do they consider its strongest areas.
The Carnegie Mellon University Binary Analysis Platform (CMU BAP) is a suite of utilities and libraries that enables analysis of programs in the machine code representation.
Symbolic computation (compilers, interpreters, DSLs, etc) is OCamlâs âtraditionalâ bread and butter, but at LexiFi we use OCaml for everything from web frontends (via js_of_ocaml), to server backend (databases, web servers), native UIs, high performance numeric code, etc; in our experience OCaml is an excellent choice for each one of these. I shudder when I think about maintaining (not so much implementing) this code in more âpopularâ languages.
Obviously: the historical strengths are compilers, proof assistants, automated theorem provers :-). In general Iâd say itâs great for reasonably fast implementations of complex algorithms.
In the engineering/data science domain I use OCaml to deal with unstructered (measurement) data, e.g., parsing logfiles, import/export from device specific databases, and controlling of test equipment. The range is from small script-like tools to convert data to complete desktop applications to run production tests in an assembly line (incl. GUI, controlling test equipment, and database storage).
OCamlâs strength here is the support for robust tools that rarely show undefined behavior in case of unexpected input data. Applications usually run everyday without errors/crashes.
Also, extending and refactoring for changed or extended requirements hardly breaks existing funcionality.
This is probably due to the strong type system and functional paradigm, and the high quality of compiler/build tools and libraries.
OCamlâs weak points are the perception as an exotic programming language which makes it harder to gain acceptance in other software teams and the development experience on Windows. The main âcompetitorsâ in the described fields are Python and C#/.NET (I am working in a Windows-centric company).
According to the described use cases, the following libs are on my top list:
I donât ever do work related to hardware. How do you actually â[control] test equipmentâ with OCaml? Is there a assembly/c api that you use and wrap OCaml over?
Yes, usually the test equipment supplier provides a C-api for their instruments. With OCamlâs C-api it is easy to write bindings for that, sometimes with the help of the ctypes library. There is also a communication/driver standard called VISA that can be used for different instruments (and therefore can reuse generated OCaml bindings for it)
Metaâs Infer is too implemented in OCaml https://fbinfer.com/ But this is still the same symbolic computation area.
From my experience, OCaml is a good general purpose language. It has a reputation of being esoteric, but in fact itâs much more straightforward than, say, Haskell. However, the ecosystem is historically much more tuned to compilers, static analysis tools, etc.
Although, there are libraries for web and whatnot, I feel when it comes to running stuff in prod itâs less mature than what youâd find e.g. on the JVM.