4 ms·
> I want the compiler to tell me when I'm making the mistake, even if it makes things choppier. You don't think the OCaml type system would do this? OCaml giv
by jnbiche 10y ago
> I want the compiler to tell me when I'm making the mistake, even if it makes things choppier.
You don't think the OCaml type system would do this? OCaml gives you just as much safety as Rust does, it just doesn't also give you no GC like Rust does. And the price Rust pays for the absence of GC is the lifetime concept, which adds a very significant layer of complexity to the language. Much like OCaml, Swift and Scala also provide very safe type systems.
Again, if you can't have a GC, then Rust is an excellent option, and the only really safe GC-less language unless you use C with FramaC or similar static analysis (and FramaC also requires lots of training and time to use, just like Rust).
- pcwalton 10y agoOwnership and borrowing are also useful for avoiding data races. OCaml solves the problem by not having any shared state at all, which is obviously a huge limitation.
- jnbiche 10y agoCurrent OCaml needn't worry about data races since no state is shared. Unfortunately, current OCaml also only exploits a single core, but it's so insanely fast that usually doesn't matter. Upcoming OCaml multicore solves the shared state and data races problem with algebraic effects[0]. It is working, it's just not yet been released in mainline OCaml. Supposedly, that will happen this year, but we'll see. 0. http://kcsrk.info/ocaml/multicore/2015/05/20/effects-multicore/ http://kcsrk.info/ocaml/multicore/2015/05/20/effects-multico...
- Bartweiss 10y agoOCaml seems like the argument against Rust's claim to trade usability for safety. It's not true for everything, I wouldn't write embedded OCaml, but it's an easy disproof-by-example for "Rust's difficulty is the inevitable price for trustworthy code!" Which isn't to say OCaml is trivial, or Rust is useless (GC and threading both being limitations). It just makes me skeptical of claims that Rust's difficulty is irreducible.
- kibwen 10y agoRust's difficulty relative to OCaml might be irreducible if we consider the difficulty added by not providing a pervasive GC, which is part of Rust's design goal and not part of OCaml's.
- Ar-Curunir 10y agoBut OCaml isn't intended for the use cases Rust is intended for: a replacement for C and C++
- pjmlp 10y agoIt depends on the use cases you mean. OCaml is actually used for many systems programming tasks that can live with a tracing GC.
- GregBuchholz 10y ago>I wouldn't write embedded OCaml But you can run OCaml on a microcontroller: http://www.algo-prog.info/ocapic/web/index.php?id=ocapic http://www.algo-prog.info/ocapic/web/index.php?id=ocapic