4 ms·
In my brief usage of OCaml, it seemed like the consensus was that the OO features were better off forgotten.
by acjohnson55 6y ago
In my brief usage of OCaml, it seemed like the consensus was that the OO features were better off forgotten.
- lostcolony 6y agoThat feels like the consensus for every language that mixes OO with FP...
- acjohnson55 6y agoI disagree. OO features are very heavily used in Scala and the languages it influenced. TypeScript and Swift particularly come to mind. I think the key here is that Scala paved the way for type systems capable of modeling OOP and FP idioms, cleaning up what OCaml attempted. Although one could argue that none of the other post-Scala languages inherit the full toolkit of typed FP features as much as Scala (pattern matching, everything is an expression, true ADTs).
- lostcolony 6y agoEvery user of Scala I've ever talked to has said something to the effect that the more they became comfortable with Scala, the more functional their code became. That includes people who have never used a functional language before taking up Scala. I've never met any who said their code became more object oriented. In fact, most "best practices" in OO eschew some of the key OO features, i.e., composition over inheritance; of those two the latter is a distinctly OO concept, and the former isn't.
- pjmlp 6y agoLike Lisp and Smalltalk?
- yawaramin 6y agoIt's not so much that, but rather that OCaml's dominant paradigm of modules and functions is just so powerful that you almost never need OOP. But when you do, it's super useful to have.