What are the biggest reasons newcomers give up on OCaml?

In my experience programming in several languages, I usually look for particular words in the error messages, looking for the signal in the noise. Here’s a typical type error:

File "./test.ml", line 1, characters 12-16:
1 | let x = 1 + true
                ^^^^
Error: This expression has type bool but an expression was expected of type
         int

Note: the only colouring used in this error message is for the ^^^^ and the word Error. Even leaving that aside, the layout of the message is not great. I need to scan through the entire message to figure out which types are mismatching. Imho if we printed a simple diff style it would be much more easily scannable:

Error: type mismatch
File: ./test.ml:1:12-16
1 | let x = 1 + true
                ^^^^
Expected:
  int
Actual:
  bool

From there we can actually talk about more sophisticated diffing capabilities for complex types.

some projects have gone overboard with these features in a way that hurts usability

Perhaps, but even a complex type mismatch error may be improved by a careful layout and diffing to make it easier for the human reader.

11 Likes