4 ms·
Curious question: If you are picking OCaml over Rust in 2020 for a new project, what is your reason for doing so (other than being already familiar with OCaml t
by ocamlskeptic 6y ago
Curious question: If you are picking OCaml over Rust in 2020 for a new project, what is your reason for doing so (other than being already familiar with OCaml through college courses, or wanting to try out something new for fun) ?
The only reason I could think of was being able to compile to JS, but other than that Rust seems to be a superior choice for all the use cases I could have used practically used OCaml for.
- vbrandl 6y agoThere is some cool stuff for OCaml, that is not (yet) possible in Rust, e.g. building a unikernel using MirageOS (https://mirage.io/ https://mirage.io/)
- sidkshatriya 6y agoIt’s very much possible to build a unikernel in rust. Google ‘rust unikernel’ and you’ll get results. In fact I would argue that rust is much more suited to write low level things like operating systems and unikernels than ocaml. Having said that mirage is very cool. It is a unikernel and it has garbage collection. So it’s easy to write robust and secure services! Yeah anything written in rust will probably be faster but then unless you’re a mega company and have mega size deployments this should not really matter to you. Mirage should serve your needs well if you need unikernels
- dwdz 6y ago1. No borrow checker 2. Compilation times
- smabie 6y agoI've never really seen them as comparable. But I would choose Ocaml over Rust because OCaml is easier, less complex, and more expressive. Also, Rust doesn't support functional programming. OCaml's performance is really quite good and I've never had problems with the GC. Unless the project absolutely couldn't tolerate GC, why would I choose a low level language like Rust over a high level language like Ocaml?
- Ar-Curunir 6y agoRust offers a better alternative to functional programming: you can mix and match imperative and functional programming without the pitfalls of arbitrary mutable state (which is where most attempts to mix and match run into problems)
- scns 6y agoOCaml can do the same
- ddek 6y agoThey’re quite different languages in almost every way. Rust is a low level systems language, where you care about memory. You may not be malloc’ing, but you’re borrowing. Conversely OCaml is an interpreted functional language. It has a much richer and more concise syntax than rust. You can’t define operators in rust. That means no ‘|>’, no parser combinators. I doubt I’ll ever write a parser in a non-ML language, after my experiences with FParsec. Rust can’t do partial application properly. I can’t compose functions in rust. Don’t get me wrong though - Rust is a fantastic language and miles ahead of similar languages in terms of functional features. The only popular C-like language that’s catching up is C#, but discriminated unions aren’t due until next autumn. Rust is better for manipulating a computer, OCaml is better for math-ey things such as parsers. You should try OCaml, even if you don’t use it you’ll learn about programming from it.
- frou_dh 6y agoThe community has the vibe of sedate unix greybeards, rather than hypebeasts.
- TheAsprngHacker 6y agoOCaml supports functional programming more idiomatically: for example, it has implicit currying, and it has a single function type instead of several function traits. OCaml is garbage collected, if you don't want to think about ownership. OCaml has the ML module system, which has tradeoffs when compared with typeclasses or traits.