Ask HN: 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?
15 comments
[ 2.7 ms ] story [ 48.3 ms ] threadHyperkit 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&...
https://signalsandthreads.com/programmable-hardware/
Also, OCaml’s garbage collector tries to minimize GC pauses. Here is a slide deck from a somewhat old talk about the now-released multicore GC:
https://kcsrk.info/multicore/gc/2017/07/06/multicore-ocaml-g...
are they generating fpga code from ocaml?
If you have already made your mind up, there is hardly a point to your question.
> are they generating fpga code from ocaml?
Yes, they have built a library called Hardcaml to design FPGAs:
https://github.com/janestreet/hardcaml
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.
So is there the equivalent of `for GOOS in linux windows macos; do for GOARCH in arm64 amd64; do go build ./...; done; done` in ocaml? And, perhaps most important in your comparison, are those resulting binaries statically linked so it's "scp deploy"?
> there is an overhead to starting new projects in it.
I'm guessing that's tightly linked to your "but the libraries don't exist" so one has to roll their own $everything?
You don't have to roll your own everything. If you need a library especially something low level or very common like a db driver it'll probably exist. And the libraries that do exist are very solid in my experience. If you need a few libraries it's pretty good odds one will be missing though.
Anyway, I wasn't trying to lobby you but you said you used it for things you would have used golang for, and that's one of golang's major selling points in my circles, so it seemed like a reasonable question to ask someone who is in that ecosystem
You will never get any OCaml fans to admit it, but yes.
It is called liquidsoap.
https://github.com/savonet/liquidsoap
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.