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)
Matt Campbell
in reply to Matt Campbell • • •Matt Campbell
in reply to Matt Campbell • • •Mark W. Gabby-Li 🐌
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.
John Goerzen
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.
John Goerzen
in reply to John Goerzen • • •But I absolutely agree on compile times. I don't know how long Rust would take to compile something on 2005 hardware but it's probably not pretty 🙂
Rust, OCaml, and Haskell all share a common lineage in their type system. Perhaps that's why I've enjoyed all of them. It's also interesting that they are such different languages but with some things in common.
Matt Campbell
in reply to John Goerzen • • •Matt Campbell
in reply to John Goerzen • • •John Goerzen
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.