OCaml And 7 Things You Need To Know About It In 2021

OCaml belongs to the ML-family of languages along with Haskell, F#, Scala, and others. All ML languages have a reputation for changing the way programmers think about programming. They are strongly typed functional languages with world-class type inference, expressive type systems, pattern matching, and automatic memory management.

OCaml has a lot to offer; including one of the most performant compliers in the world and it incorporates a variety of different paradigms into its functionality. Although it’s hard to call it a mainstream language, it is heavily used by well known companies all over the world, including Facebook.

To help you get a head start on becoming an OCaml connoisseur, here are 7 key things you need to know.


Also known as the “billion dollar mistake”, null references are now generally recognized as a bad idea. As with most ML languages, OCaml doesn’t have them. The reason for this is because the ML languages have focused on correctness; if it compiles, then it just works.
To represent a potentially nonexistent value, OCaml forces programmers to wrap them in something called an “option”. When using options, OCaml forces programmers to explicitly handle the case where the value doesn’t exist. This removes an entire category of bugs common in mainstream languages like C and Java.


Traditional data structures like enums can be quite limiting when trying to model real world domains. In mainstream languages, this leads to buggy implementations that are overly complex and hard to maintain over time.
OCaml, like most other ML languages, has a killer feature called “variants” which are user defined types and data structures that make domain modelling incredibly intuitive. Despite its simplicity, variants are likely the most powerful feature of OCaml’s type system.


In mainstream languages, refactoring large sections of a codebase is generally a scary experience. The programmer(s) must keep a lot of context in their head while doing them, and a lot can go wrong.

In OCaml, the compiler truly has your back. Thanks to OCaml’s expressive type system, the intent of the code generally lives in the codebase itself, not in someone’s head. Programmers change a type definition, and follow the friendly error messages provided by the compiler until the application compiles. Once it compiles, it generally just works.


OCaml isn’t exactly a new kid on the block. Released in 1996, it follows on from Caml, released 9 years prior. In fact, it came out the same year as Java.

Since then, OCaml has had a lot of time to refine its type system, and can compile to many platforms including JavaScript and native platforms (e.g. Linux, Windows, macOS, iOS & Android). It has a proper package manager (Opam) and a modern build system (Dune).


While OCaml is currently single-threaded, multi-core is actively being developed by an organization called OCaml Labs. For more about OCaml Labs, here is an excerpt from their website:

“We are focused on pushing OCaml and functional programming forward as a platform, making it a more effective tool for all users. We work on all aspects of the OCaml developer toolchain.”


All ML languages have the advantage of static type systems, which dramatically optimizes compilation and execution. Dynamically typed languages have to bite the bullet of checking the types of variables in order to prevent type mismatch errors, which are not possible under a static type system.

Xavier Leroy, one of the core developers of OCaml, has stated that “OCaml delivers at least 50% of the performance of a decent C compiler”, and results from the great computer language shootout provide evidence that OCaml is the second fastest programming language, right behind C, although direct comparisons are obviously quite difficult.

However, it is worth mentioning that OCaml is both type safe and memory safe, while C is neither.


Given everything you now know about OCaml, you might be confused as to why you don’t see recruiters asking for it on LinkedIn as much as you’d expect. Well, the reason for OCaml’s lack of popularity isn’t necessarily a fault of the language itself. After all, Java did spend $500M to market the language. The comparison and competition with C are clear in how the language was designed, however C had a massive head start on getting into the mainstream. Basically, every UNIX system shipped with C pre-installed, and out of the box, OCaml didn’t actually provide that much functionality.

The focus on performance optimization might be a cool thing to argue about on Reddit, but it doesn’t exactly entice new developers to abandon the language they’re used to and the libraries that make their lives easy to switch to a confusing environment that can sort arrays a little bit faster. It was due to OCaml’s failure to get their foot in the door that resulted in it being dominated by other languages, even if the core foundation of OCaml was fundamentally superior.

That being said, the popularity of OCaml has grown significantly in recent years, and there is a thriving community that continues to develop tools and libraries to assist in development. Besides, being able to say on your resume that you’re proficient with a language that’s almost as efficient as C while achieving both type and memory safety is quite the power move, and many developers say that learning the syntax of OCaml actually made their programming in other languages neater and more efficient, so even if you don’t actually use it in practice, OCaml could still be quite a useful language to learn and add to your skillset.


We’ve scoured the advertised and current job offerings that require OCaml as a prerequisite to come to an estimated mean salary.

In San Francisco, roles begin at around $90,000 per year all the way up to $230,000 in lead engineer roles. The average salary of roles that required OCaml was $155,000.

New York salaries were slightly lower, ranging from $80,000 to $220,000 in senior software dev roles with the average hovering just above $135,000.

If you’re from Austin Texas, the OCaml jobs are a little scarcer but an average salary of $120,000 per year is what programmers can expect using this discipline.

Next Steps

If you enjoyed this blog make sure to check out these blogs as well: NodeJS and 5 Things You Need to Know About It In 2021 or .NET and 5 Things You Need to Know About It In 2021.

Kofi Group is proud to be a source of knowledge and insight into the startup software engineering world and offers a multitude of resources to help you learn more, improve your career, and help startups hire the best talent. If you are interested in learning more about what we do and how we can help you then get in touch or watch our Youtube videos for additional information.