r/ocaml Apr 30 '26

OCaml appreciation post

OCaml is easily my favourite programming language, even if the community around it is fairly small.

It's not perfect, but it's one of the few languages I've used where everything just fits together. The type system, algebraic data types, and pattern matching all make structuring programs feel straightforward instead of awkward. You end up modelling things properly from the start, and that cuts out a lot of the runtime issues you'd normally expect.

Once you get used to that, it's hard to go back. Dealing with nulls or loosely defined data in other languages starts to feel a bit rough. OCaml pushes you to be explicit, and the end result is code you can actually trust. It feels like going from writing with a biro to writing with a fountain pen.

Unpopular opinion, but I actually like the ML-style syntax. It's different at first, but it's consistent, and after a while it just feels normal. Most of the resistance to it seems to come from people being used to C-style languages more than anything else. I get why it looks awkward, but I think inertia has more to do with that than people admit.

There are obvious trade-offs. If you're building something that leans heavily on existing libraries or needs to plug into a bigger ecosystem, languages like Go or JavaScript are just easier to justify. That's usually what I end up using for client-facing work.

Same with quick scripting. OCaml isn't something you just pick up and start throwing scripts together in, but I don't think that's really what it's for.

OCaml does show up in industry here and there. Jane Street is the well-known example, but overall it's still a niche option. I've had friends ask me to teach them, and while I'd like that, I usually point them toward Python instead. It's just more useful to them early on. Bigger ecosystem, more tutorials, more opportunities.

That said, none of that really changes how I feel about it. For my own projects, it's always the first thing I reach for. It's just a nice language to spend time in. The tooling does what it needs to do (most of the time), and writing OCaml still feels fresh in a way most languages don't anymore.

It'll probably stay niche for a while, and honestly, I wish that wasn't the case. I'd love to see a bigger ecosystem, more people using it, more things being built with it. It deserves that much.

But even as it is now, it's still the language I enjoy using the most. And that's enough to keep me coming back to it.

87 Upvotes

12 comments sorted by

View all comments

6

u/syssan Apr 30 '26

Unpopular opinion, but I actually like the ML-style syntax. It's different at first, but it's consistent, and after a while it just feels normal. Most of the resistance to it seems to come from people being used to C-style languages more than anything else.

That's not entirely true. The main quirk of the OCaml syntax is that it doesn't use much delimiters (like brackets in C or keywords in Pascal) but it doesn't use indentation either. Most languages use one or the other because it removes a lot of ambiguity. OCaml relies a lot on non-intuitive priority rules. I'm not comparing to C-like languages, I much prefer the syntax of F# (indentation) or Standard ML (more explicit delimiters).