Hacker News new | ask | show | jobs
by Hirrolot 1221 days ago
That would not be a comprehensive comparison, but:

- OCaml is definitely tailored for more "high-level" tasks, such as writing a programming language or a theorem prover (there are many of them in the OCaml world, and even Rust was initially written in OCaml, as you've mentioned). OCaml has a GC, which might be a problem under certain circumstances.

- Rust has a far better ecosystem despite being a younger language. You can just compare the number of packages on crates.io and OPAM.

- OCaml _sometimes_ has some more fancy type features, such as functors (modules parameterized by other modules), first-class modules, GADTs (Generalized Algebraic Data Types), algebraic effects, and the list could go on. It doesn't have type classes or an ownership system though.

- OCaml is more ML-like, while Rust quite often feels C-like. For example, you have automatically curried functions in OCaml and the omnipresent HM type inference.

- OCaml has a powerful optimizer called Flambda [1], which is designed to optimize FP-style programs.

Having written some code both in OCaml and Rust, I can say they are in a lot of aspects quite similar though. They both take a more practical POV on programming than Haskell, which affects language design quite evidently.

[1] https://v2.ocaml.org/manual/flambda.html