4 ms·
I made a similar transition (1 year Haskell, 2 year OCaml) and this pretty matches up my experience. Some more points: 1. Compiler speed: a clear win for OCaml
by crvdgc 2y ago
I made a similar transition (1 year Haskell, 2 year OCaml) and this pretty matches up my experience. Some more points:
1. Compiler speed: a clear win for OCaml
2. OCaml 's module system is more explicit (always qualified Map.find). Haskell's type class system is more ergonomic (the instance is found through its type, so no explicit annotation needed, e.g. fmap fmap fmap, where the second must be the Reader's fmap).
3. > If I come to an existing OCaml project, the worst thing previous developers could do to it is have poor variable names, minimal documentation, and 200+ LOC functions. That’s fine, nothing extraordinary, I can handle that.
Though it's not common, but functor-heavy codebase does give you a headache. On the other hand, unifying type class instances across packages is no fun either.
4. OCaml's mixture of side effects and pure code tends to encourage using that in libraries and codebase. So expect more speed and more crashes.
- 59nadir 2y agoMy problem with OCaml is that it's in an awkward spot where the runtime offers very little, so it can't really be compared with most Haskell use cases where you want green threads (with preemptive scheduling), transactional memory, and so on. The runtimes of the languages aren't really equipped to do the same things, basically. So that leaves OCaml in a spot where it instead competes with more bare runtimes, i.e. compiled languages like Odin, Zig and Rust. In terms of straight forward control of behavior OCaml loses handily to both Odin and Zig. Likewise with how much effort you have to put in to get good performance out of what you're doing, despite what OCaml enthusiasts say it's not magic fairy dust, you still have indirection in terms of expressing your desired allocation patterns, etc., in OCaml that you wouldn't have in Odin/Zig, making it less appropriate for those situations. So, OCaml's final upside: Language simplicity... It's not remotely small or simple enough to be compared to Odin. Zig (despite their best efforts) is still a simpler and leaner language than OCaml as well. Zig also has the interesting quirk that it can express functors just with its `comptime` keyword (returning structs with parameterized functions, all done at compile-time) in a much more straight forward way than OCaml can, making it almost a better OCaml than OCaml in that particular respect. Given the above it seems to me that there's always a [obviously] better language than OCaml for a task; it can't really win because whatever you're doing there's probably something that's better at your most important axis, unless the axis is "Being like OCaml". I liked writing OCaml with BuckleScript, though, compiling it to JS and using OCaml as a JS alternative.
- pjmlp 2y agoIt has almost 30 years of history, and ecosystem, while those are barely at 1.0.
- 59nadir 2y agoOCaml's ecosystem is significantly smaller and less well developed than Haskell, and since you've given up on tight and clear control of allocation strategies by choosing OCaml, Rust looks like a very good alternative, which has an absolutely massive ecosystem in comparison to OCaml. Again, the main issue with OCaml is that it really doesn't have an axis it's even in the top 5 of, except maybe compile times. I understand people who like OCaml. There's a lot that's good about it, but it just doesn't have any edge. There's almost no way to pick OCaml and objectively have made a good choice.
- pjmlp 2y agoLost me, weren't we talking about Zig and Odin, versus OCaml? Also, OCaml is mature enough for Jane Street, Cisco, Docker, among others. Which most likely will never pick neither Zig, nor Odin.
- 59nadir 2y agoI'm pointing out exactly the same thing I was in my original post: There is no axis on which OCaml is top 5. If you want control, there are better languages, if you want ecosystem, almost every language beats it. It's practically speaking never the best choice for anything. Basically the only reason anyone would ever choose it (for pretty much anything) is because they like it.
- pjmlp 2y agoZig and Odin beating OCaml, ok.