Peel the Onion: Why OCaml Seems Difficult When it's so Easy

Peel the Onion: Why OCaml Seems Difficult When it’s so Easy

——

OCaml is not inherently complex. It’s actually one of the simplest languages I’ve ever used — much easier to reason about than JavaScript or TypeScript, in my opinion.
So why do so few people use it?

I’ve been writing about OCaml for a while now. Coming from the web-dev world and transitioning into systems programming, I’ve noticed something:

The learning experience of OCaml feels like peeling an onion.

Let me explain.


We Teach OCaml Like an Onion… Instead of a Ladder

Learning OCaml today often means dealing with:

  • too many layers at the same time
  • too many concepts too early
  • too many assumptions about prior knowledge

We should teach OCaml the same way math teachers introduce concepts to kids.

When you teach natural numbers, you don’t immediately dive into rationals, imaginaries, coordinate transforms, or rotations.
You give learners only what they need now so they can build intuition first.

It’s not “lying.”
It’s good pedagogy.

If we want newcomers to adopt OCaml, we must meet them where they are — not where we are.

And if we’re worried about beginners misusing advanced tools or producing bad code, the solution is simple:

Just don’t show them everything at once. Limit the toolset until they’re ready.


Teach Through Examples

Although we love these topics, most newcomers don’t want to build a parser, an interpreter, or a compiler toy.
They just want to write a program that runs.

The Rust community understands this perfectly:

  • Your first contact with Rust is running a small project.
  • You don’t know borrow-checking rules.
  • You don’t know how MIR works.
  • You don’t know lifetimes.

That’s the mindset we should adopt: Show first, explain later.

Let intuition grow through repeated practical experience.


Newcomers Matter (More Than We Admit)

Most OCaml users today come from highly specialized backgrounds — formal methods, academia, compilers, fintech, research labs — and that’s great.

But if we want the community to grow, we must reach a different kind of newcomer:

  • web developers
  • backend engineers
  • self-taught programmers

In other words: people who simply want to try a new language.


DX Matters: Small Details Have Massive Impact

Velocity matters — especially for beginners.
Sometimes improving the experience means removing a single flag from a command.

If we want more people to fall in love with OCaml, we must:

  • reduce friction in the first 10 minutes
  • streamline project creation

Think of it this way: less configuration = less documentation for us :laughing:


Too Many “OCamls” for a Beginner

Choice is good.
But for beginners, too much choice feels like fragmentation.

We should provide one clear, opinionated, beginner-safe path.
They can explore everything else later.

Coming from the web world, I’ve learned that technologies don’t win because they’re elegant.
They win because they align with existing intuition.

React is a perfect example.
It didn’t win because it’s the best design (I personally think it isn’t).
It won because it felt like JavaScript — it matched developers’ existing mental models.

OCaml has the opposite problem:

There isn’t one OCaml. There are multiple OCamls.

Beginners have no idea which version they’re supposed to follow.

This creates paralysis:

  • “Which style is the real OCaml?”
  • “Will what I learn today work tomorrow?”
  • “Why does this example look nothing like that other example?”

My Current Goal in the Community

This is why I’ve been writing OCaml content:
to help newcomers enter the language comfortably.

It’s a work in progress, but my personal mission is to:

  • teach OCaml through examples
  • show first, explain later
  • prioritize intuition
  • reduce conceptual overhead
  • build a smooth path for people coming from mainstream backgrounds

Final Thought

If we want OCaml to grow, we need to onboard people the same way we teach children mathematics — or the same way Rust introduces new developers:

with intuition, clarity, and progressive complexity.

OCaml deserves that.
Newcomers deserve that.
OCaml documentation maintainers deserve that.

10 Likes

This resource is great, I have to say.

4 Likes

Indeed, very good resource.

This part, however, did not age very well:

Another example is the website
https://replit.com/
which offers online environments for a number of languages, among them OCaml.

I don’t know what replit looked like before, but today it’s just a website with AI-infested jargon and I see no trace of an online environment. I’ll notify the authors to remove the reference.

1 Like

I had no issue with learning the « plain » language, but for real projects, we generally need libraries.

I remember having an hard time assembling Dream/Caqti/ppx_rapper. (But I have to admit the Dream documentation is very nice and should be looked at like a model). Then I find the OCaml Cookbook a nice idea.

Then some documentation which are going further is welcomed. I have in mind « more OCaml » which gives a PDF file producing, « Real World OCaml » (even if some people dislike its Janstreet Base usage).

I have translated some of the more interesting examples in the first third or so of the book to use the standard library, and occasionally parts of Containers. I can’t remember exactly why I started doing this, but I may at one point throw them in a repository and publish them somewhere.

1 Like

OCaml is not inherently complex. It’s actually one of the simplest languages I’ve ever used — much easier to reason about than JavaScript or TypeScript, in my opinion.
So why do so few people use it?

I think all the points are things that it would be worthwhile to improve on, but they are not why OCaml is not mainstream.

I remember seeing this talk which explores why mainstream languages are mainstream, and the reason is very rarely that they are friendly to beginners. For instance javascript is not popular because its a good language or has good doc, but because you have to use if you want to program the browser.

Other languages like ruby had a killer app, C# has a captive platform, typescript was a quick upgrade to an already popular language.

Rust might be an exception, but is it really mainstream ?

4 Likes

Not going to argue for it :–) but one theory I sometime entertain about rust’s popularity with programmers is that it lies at the intersection of their more than often irrational thoughts about software performance and their excitement for solving programming puzzles which reifies here through some sort gamification of the borrow checker.

5 Likes

I think its reputation as a sort of Java alternative language certainly has something to do with it.

But basically being both “cool” and “fun” is an intrinsic quality of the language, when having a captive platform is not.

Very nice talk… there are many thing… but there are two of them which are important:

  • Education: In France many CS courses are offered in Python… many people will be Python oriented (but some courses are in OCaml). In the 1990’s I was exposed to Caml… it is perhaps a reason I am here now,
  • Ecosystem: people want their job to be done, then when I had to setup a little dynamic website, the dream/caqti/ppx_rapper combo was a real killer-app (no need to type htmlspecialchars(...) for each string to output was restful !)… But lets say I work for a company were Oracle or MS SQL Server should be interfaced… I guess I would have an hard time. Matplotlib is also a Python killer-app (a very well documentated one… We shouldn’t minimise this aspect… Dream example should be a cap to follow). Nowadays, I am struggling to have a GUI library on Windows. OCaml doesn’t seem to be the easiest path.

I note that with Ocsigen, OCaml can have another killer-app. Its integrated RPC can be nice for complex client-server interactions (once it will be Eio compatible, it will be perfect… remember the quick upgrade of the video. Monad programming can be tricky).

1 Like

After like 15 years of wandering & research compiler/languages around, I still find myself back to ocaml & build new toy interpreter/vm in an hour to test my idea.

Imagine relearn it in a day and can contribute back to library in ecosystem right away (even when I felt like just guessing ).

I have released some tiny rubygems in the past for ruby community which I feel like toys everyone can share without much hesitation. But it was very straightforward to do so. Neovim colorscheme is easy enough to just public it on github repo.

But in case of Dune/Opam, even when I can contribute back, Im not sure yet.

The language is simple & safe without manual mem-man while stay relatively as fast as Rust. Any VM on top of it could even just 20% taxed in speed (~LuaJIT level).

Which is great but installation & its related batteries :battery: aren’t working all the time.

I can say in ML, no other better choice I would take over Ocaml but it’s surely not for everyone. Also there is its dialect on dotNet called F#, not many ppl use it except PhD level dev I guess.

Let’s say low-level stuffs has Zig, mem-safe has Rust, web has Js/Ts, Microsoft platform has dotNet/C#, enterprise server use Java, then come ML/Data/Researchers has Haskell/Ocaml :man_shrugging:

My friend also suffered from Cardano maintenance with single threaded Haskell compiler version, where every change to project require hours to be seen… It could be the same with Ocaml for single threaded compiler to relink every library it included.

I know recently someone written new package manager (Alice-Ocaml) to handle Ocaml ecosystem alike to what Cargo did for Rust, which is very first step into better Ocaml instead of confusing ppl with dune/opam ( why would I need two separate programs to manage my project ?)

1 Like

Hi Emile, thanks for the thoughtful comment.

I’ve seen the talk before and yes, history and platform lock-in play a huge role, but I believe they’re not the full story:

JavaScript isn’t popular just because it was the only option for the browser. If that were the only factor, Flash would have remained dominant. JS won because the ecosystem around it eventually became easier to use than the alternatives. The language itself wasn’t good, so developers compensated by building libraries, then frameworks, and ultimately TypeScript.

React is a perfect example: not the “best”, but the simplest to understand at scale compared to other frameworks of its time.

I didn’t emphasize enough in the blog but I also think that content creators play an important role, the community grows when it has people explaining, teaching, and making it feel approachable. That’s something I want to contribute.

1 Like