3 ms·
I can kind of understand the author's complaint. A problem with OCaml is there are several different ways to achieve the same thing, and they're not compatible.
by sparkie 3y ago
I can kind of understand the author's complaint. A problem with OCaml is there are several different ways to achieve the same thing, and they're not compatible.
For example, you can do OOP-like interfaces/abstract classes with `class virtual`, but classes and modules don't mix together nicely. Your virtual class cannot abstract over modules, nor do functors abstract over classes.
So you end up either using modules/functors pervasively, or using objects pervasively. It's like there's two separate languages competing for use.
Using modules seems to be more common, but it overshadows some features of OCaml's object system which are pretty unique to it and useful: row polymorphism and functional objects.
Obviously, functors have a clear performance advantage because they're expanded at compile time, and objects have the vtable overhead.
I think it would be interesting to see a variant of OCaml which goes all-in on the object side of things. Strip away the modules and functors and a provide standard library based around functional objects.