3 ms·
Besides GC and the lightweight syntax (relative to Rust), what is it about OCaml that makes it so wonderful for implementing complicated algorithms?
by giornogiovanna 7y ago
Besides GC and the lightweight syntax (relative to Rust), what is it about OCaml that makes it so wonderful for implementing complicated algorithms?
- pjmlp 7y agoExactly that, lock-free algorithms are specially hard to get a correct implementation without tracing GC support.
- terminaljunkid 7y agoWhy?
- pjmlp 7y agoHere is an overview, read also the comments. https://concurrencyfreaks.blogspot.com/2017/08/why-is-memory-reclamation-so-important.html?m=1 https://concurrencyfreaks.blogspot.com/2017/08/why-is-memory...
- Yoric 7y agoWell, the big one is GC. Here are a few others: - both polymorphic variants and GADTs are extremely powerful mechanisms to let you keep track of invariants, in a manner that cannot be replicated readably in Rust so far; - OCaml's pattern-matching is a bit more flexible than Rust's ; - (thanks to the GC) OCaml's closures are much more flexible than Rust closures; - I guess OCaml's blindingly fast exceptions can be useful for some algorithms, although I haven't really experienced the need for them myself. Again, that's not to say that Rust doesn't have great stuff for it (affine types 4eva!) or that OCaml doesn't have its own limitations – Rust is currently my main language and I do not regret it. But there are some algorithms that I really don't want to write in Rust. Recently, for instance, I stumbled upon this: http://weblog.jamisbuck.org/2010/12/29/maze-generation-eller-s-algorithm http://weblog.jamisbuck.org/2010/12/29/maze-generation-eller... . Trivial algorithm, trivial to write in OCaml, feasible but much less straightforward in Rust.