OCaml is a battle-tested programming language with an emphasis on correctness and efficiency. In domains where both are important, it can really shine:
- Simple but powerful type system helps to model data and logic correctly and catch errors quickly
- Safe by default but pragmatically allows you to bypass safety checks when efficiency is critical
OCaml is an old language (current implementation is about as old as Java, with ancestry going back to the '70s). It offers a pragmatic mix of programming styles:
- Functional and modular: this is the default–enables writing clean, efficient code
- Imperative: if you really just need a while loop and some mutation, OCaml has those too–it's just that developers don't need them that often with OCaml's idiomatic functional style
- Facebook: Messenger web frontend, Ads, various code safety and analysis tools
- Bloomberg: derivatives analysis platform
- Docker: virtualization internals, Docker for Mac and Windows
- Jane Street Capital: core trading platform
- SAP Bangalore: internal tooling
- Elastic (i.e. the ElasticSearch vendor): data security tooling
- Many others
OCaml streamlines the process of development and forces many code quality issues to be handled sooner rather than later. Concretely:
- Fast, Go-like build speed helps iterate and ship quickly
- Type system catches many classes of bugs; people regularly experience 'if it compiles it works'
- Module system forces clean, layered code organization
- Warnings system forces code cleanliness (i.e. removing deprecated and dead code)
OCaml ships out of the box with much of the code quality tooling that other languages need to add on linters and static analyzers for. This helps to reduce maintenance burden of codebases over time.
Although powerful, OCaml by design discourages complex (what developers call 'magical') code, instead favouring simple, explicit code. Developers can get surprisingly far with just types and functions. And OCaml's 'secret sauce'–its simple yet powerful module system–lets developers enforce strong contracts between system components. What in other languages may require microservices with service protocols–will in OCaml require only a module in the app.
OCaml is also very stable. Its maintainers take backward compatibility very seriously and work on large-scale improvements over the time scale of years to ensure everyone has an upgrade path. Old OCaml codebases usually compile with very few changes.
It's a niche language with a smaller (but growing) community and ecosystem. Developers in the team may need to invest a little more time to be more 'in tune' with the community, ecosystem and packages, and general best practices. Fortunately, the community is welcoming and tight-knit, with a lot of knowledge sharing happening regularly on the forums.
OCaml also can run only one thread at a time, much like Node.js/Python/Ruby. (This is to enable an efficient, low-latency garbage collector.) However, its support for system threads as well as asynchronous promises is excellent, and many use cases simply don't need or can easily work around multiple parallel threads.
It really depends on your filtering process for candidates. There is a large pool of programmers who would be excited to program in OCaml. They are probably not located where you are though, unless you're somewhere like New York or San Francisco. If you hire remote you will have a large pool of skilled candidates.
Ultimately the decision rests on many factors, but OCaml offers some quite attractive outcomes:
- Getting rid of bugs like 'null pointer exception' crashing your service at 3 am
- Apps that can be iterated on quickly and safely
- Performant apps that don't guzzle system resources
- A clean, understandable, and maintainable codebase over time
If you're interested, here's where you can learn more about OCaml and what it can do: