It's pretty comfortable for organizing and refactoring because of the nice module and type system. And once you grok Dune (the build system) you can get going pretty quick. Builds are very fast compared to most of the languages I use at work. And if you're not doing anything egregious the optimizing compiler (Flambda) can usually be within ~2x of C for most things. When it's not dropping down to C is very easy because the FFI system is very straight forward, and has built in support in Dune.
It is lacking a bit in libraries and when you need to drop down to imperative features you may find it a bit rough. For example not having a return keyword can make it annoying to port over libraries.
Overall I like it because I think the pros outweigh the cons, but I've also been using it for a decade so I'm probably getting set in my ways now. I'd say it's worth trying at least to understand Sum types (and maybe GADTs), and use a language with first class modules, it can change your approach to problems once you see some extra tools.
Like, what's java's niche? I'd say it doesn't really have one anymore, it's just a generalist language. Ocaml is also a generalist language, but it has much better language paradigms, is safer, more concise, has more features with less baggage, etc. It's just good all around.
As a functional programming advocate, I'd point to safety, readability, and development velocity as features, but those are all around good and desirable, not really a niche.
I wish more companies were using languages like ocaml/f#/clojure vs c++/python/java when there is no specific reason to use the former.
Like java, python, c# 'slants' towards web services and maaybe CRUD apps, C++ 'slants' towards games and graphicly complex apps.
I'm well out of my FP fanboy phase now but ocaml feels great for my favorite parts of that without being judgmental when I'm not in the mood.
Very true! I've used mutations and imperative OCaml quite a few times. Sometimes it was for performance reasons (I've been working on a web server library), and other times when loops either made the implementation a little easier to read, and/or helped avoid some allocations. I am glad that the language is pragmatic enough that I can still use mutation or imperative code where it makes sense, while still being able to present a nice clean api on top.
I sneak it in at my jobs when I can justify it but it seems like there are very very few jobs that use it primarily.
> it but it seems like there are very very few jobs that use it primarily.
I completely agree. I never tried looking for an OCaml job mostly because there weren't enough options at-least in the US (I'm based in USA), and I am picky about who I work for and wasn't interested in exploring job opportunities at companies working on cryptocurrencies. I just got lucky that I stumbled upon two different companies that used OCaml. The first time around I applied for the job because of OCaml, the second time around it was because I liked the company and OCaml was an added bonus on top.
The language I work in is not even one of my top priorities when looking for work, but still it would be cool. I'm lucky enough to have enough freedom to work in it from time to time, which is good enough for me.
Thanks for the response!
Same! I've made the mistake of overlooking certain things just because I wanted to get some real world OCaml experience in the past, and I will not make the same mistake again.
At my current job I mostly use OCaml and Python, with some Typescript for whenever I need to touch a frontend application. As much as I like using OCaml, I'm more thrilled about working on a team where I enjoy working with everyone, and having a work environment that provides flexibility about picking the best tool for a job. Most of my OCaml hacking still takes place on my free time, and on my personal open-source explorations :-)
> Thanks for the response!
You are welcome! Sorry if my responses weren't too useful with respect to using OCaml at work.
It's a nice change of pace from the Ethereum ecosystem.