HACKER Q&A
📣 _fol8

What Is OCaml Used For?


It looks like an interesting programming language (and the support for multiprocessing looks exciting). However I haven't heard of it used in any large projects that I'm aware of. Some of the packages that would be useful for the projects I might want to work on are years of date, although that could just be selection bias. (But, gtk bindings? Am I missing something?)

Is it more of a research language as opposed to a "making applications" developer language? Can someone provide a little background?


  👤 giraffe_lady Accepted Answer ✓
Not every language has a point, really, some of them just exist. You can always find a reason why they continue to. But that doesn't mean it's going to be the best or even a good choice for anything in particular, necessarily.

Many of the core language fundamentals are incredibly sound, and it has a very good performance profile for the features you get. The type system is top notch and and the module system is afaik the only one of its kind and sophistication in a mature language. These all offer benefits that accrue over time, and I think ocaml systems age particularly well and remain easy to maintain. The syntax is french and bad but you get over that in the first year and truly it doesn't matter in the long run.

But yeah the libraries! It's good for when you weren't going to use them anyway because they don't exist. Which is why I think you see it used for research and complex internal finance shit, stuff you couldn't or wouldn't want to use external code for. But it's not as much as a struggle as you'd think, the type system basically feels like a PEG system to start with so it's easy to build robust interfaces to outside systems when you need to.

Personally I mostly use it for things other people use Go for. It has most of the same strengths but not the main weaknesses. But yeah I would kill for a solid modern TUI framework like charm. If I'm writing throwaway code I use something else because there is an overhead to starting new projects in it. If I'm writing a tool I hope or expect to use for years it's my go to though.


👤 jonjacky
"MirageOS is a library operating system that constructs unikernels for secure, high-performance network applications across a variety of cloud computing and mobile platforms. ...

MirageOS uses the OCaml language, with libraries that provide networking, storage and concurrency support that work under Unix during development, but become operating system drivers when being compiled for production deployment. ...

MirageOS 4.0 was released in March 2022, preceded by ... MirageOS 1.0 in December 2013. All the infrastructure you see here is self-hosted. ..."

https://mirage.io/

So this has been going on for 9 years, I presume someone is using it.


👤 kratom_sandwich
Secretive trading firm Jane Street uses OCAML: https://www.janestreet.com/technology/

👤 mdaniel
Semgrep is the most famous one I could think of offhand: https://github.com/returntocorp/semgrep/blob/v1.2.1/Dockerfi...

Hyperkit from the docker/moby folks is another: https://github.com/moby/hyperkit/tree/v0.20210107

And while niche, Coq is not exactly unheard of: https://github.com/coq/coq/tree/V8.16.1

If you weren't already aware, GitHub supports searching by the repo's more prominent language: https://github.com/search?o=desc&q=language%3Aocaml&s=stars&...


👤 simplecto
There is a really cool Audio and Video streaming language written in Ocaml.

It is called liquidsoap.

https://github.com/savonet/liquidsoap


👤 JoeyBananas
> Is it more of a research language as opposed to a "making applications" developer language?

You will never get any OCaml fans to admit it, but yes.