There was recently a popular article about why someone chose OCaml as their primary programming language, which prompted this response about why someone else chose Lean: kirancodes.me/posts/log-ocaml-… I haven't tried Lean yet, but the article makes a point about OCaml that I think is worth discussing in contrast with Rust. (continued)
in reply to Matt Campbell

That first point, about the OCaml compiler being conservative with optimizations, actually makes me more interested in OCaml, as it contrasts with my current favorite language, Rust. And I've verified that OCaml does in fact compile itself quickly, even on my modest single-board computer. But of course, the tradeoff is that OCaml requires a runtime written in C, thus adding an extra layer of unsafe code compared to Rust.
in reply to Matt Campbell

In my experience, it has terrible code generation.

Case in point, I once looked at the assembly it generated for zeroing a statically sized array of POD types, and it was amazing how overcomplicated it was.
There is enough information at the AST level to branch on types and simplify the code gen in cases like that from my understanding of how things work.

This is just one example, so take it for what it's worth.

in reply to Matt Campbell

I used to use #OCaml quite a bit, though that was a number of years ago, and I use #Rust a lot now.

One of my main gripes about OCaml is how it wasn't very practical in some ways. There was no way to open a file read/write (very common for, say, databases), and because it lacked things like Haskel's typeclasses or Rust's traits, you'd use different functions to seek on a file opened for input vs. one for output.

Looks like it's still the same.

in reply to Matt Campbell

There is something really elegant about #Haskell, and its isolation of "pure" functions (which can't perform I/O) from impure functions, as well as general data immutability, make for nice designs that are easy to reason about, and excellent recursion handling also feeds into that.

That said, memory usage in Haskell can be hard to reason about, and Rust gives some of those guarantees with its "mut" keyword.

I do a lot of systems programming, so would mostly go for Rust these days.