What are the biggest reasons newcomers give up on OCaml?

As a newcomer to OCaml, I’ve been jotting down my pain points (and pleasant discoveries too!). Here’s a couple ones:

  • Package management. opam is fairly simple to use, but having everything be in a global namespace by default is quite frustrating. It reminds me of the Python ecosystem using pip and virtualenv. I miss lockfiles and local dependencies by default. I also want multiple package versions to be possible.
  • OCaml syntax is slightly difficult to understand. This isn’t that big a deal, I mostly picked it up after a day or two of writing code. But if you’re used to writing statement based languages with blocks, OCaml is not very intuitive. I wish I could toggle between Reason syntax and OCaml in my editor, so I can see how stuff would be written in a more mainstream syntax.
  • Syntax errors. Syntax errors don’t give any explanation other than “syntax error”, a single line of code, and the location. Sometimes the error is actually before the given line. There also doesn’t seem to be much error recovery in the parser.
  • Documentation. Libraries often don’t have a lot of documentation and what they do have is often out of date. The OCaml docs site is lovely though!
  • IO. It’s not very clear how to print debug or write to files. I usually end up asking Claude for help. Tbh it might be nice to have some simple APIs for this like Rust’s fs::read_to_string or fs::write.

On the positive side:

  • Type inference. It’s really nice not having to write out types when prototyping or editing code. You can make a change to a variable’s type and won’t need to edit a bunch of functions.
  • Garbage Collection. This is a dumb one but coming from Rust it is genuinely nice being able to just use variables multiple times lol.
  • Simplicity. I get the same vibe that I get from Go where the core language is fairly simple. The code does what it says and little is left implicit. I can spend more time writing code and less time writing the language if that makes sense.
  • Interfaces. Interface files are a really nice way to think through your code and boundaries.
19 Likes