6 ms·
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?
- mdaniel 4y agoSemgrep is the most famous one I could think of offhand: https://github.com/returntocorp/semgrep/blob/v1.2.1/Dockerfile#L57 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 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 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&type=Repositories https://github.com/search?o=desc&q=language%3Aocaml&s=stars&...
- iforgotpassword 4y agoI remember it from mldonkey from back in the day... Afaik the first ed2k capable client for Linux.
- kratom_sandwich 4y agoSecretive trading firm Jane Street uses OCAML: https://www.janestreet.com/technology/ https://www.janestreet.com/technology/
- b20000 4y agoi’m curious how they get the low latency performance they need when using a language like ocaml.
- nequo 4y agoOne answer is FPGAs: https://signalsandthreads.com/programmable-hardware/ 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-gc/ https://kcsrk.info/multicore/gc/2017/07/06/multicore-ocaml-g...
- b20000 4y agoyeah ok, no interest in a language with a GC. i’ll stick to c++. are they generating fpga code from ocaml?
- nequo 4y ago> yeah ok, no interest in a language with a GC. i’ll stick to c++. 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 https://github.com/janestreet/hardcaml
- giraffe_lady 4y agoNot 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.
- mdaniel 4y ago> Personally I mostly use it for things other people use Go for. It has most of the same strengths but not the main weaknesses. 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?
- giraffe_lady 4y agoI don't know, I know multiplatform binaries are truly important for some groups but in my entire career I've never actually needed that a single time on any project. Static linking isn't automatic but you can do it. People tend to always assume you can't? idk why though maybe it used to be a thing. 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.
- JoeyBananas 4y ago> 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.
- belmont_sup 4y agoI admit it. I enjoy it but can’t reasonably suggest it to an employer. F# in the other hand.
- simplecto 4y agoThere is a really cool Audio and Video streaming language written in Ocaml. It is called liquidsoap. https://github.com/savonet/liquidsoap https://github.com/savonet/liquidsoap
- jonjacky 4y ago"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/ https://mirage.io/ So this has been going on for 9 years, I presume someone is using it.