4 ms·
Rust prevents data races, OCaml/F# don't provide such guaranties. Though it isn't so much of a problem in OCaml since it doesn't have concurrent threads.
by stonemetal 10y ago
Rust prevents data races, OCaml/F# don't provide such guaranties. Though it isn't so much of a problem in OCaml since it doesn't have concurrent threads.
- jnbiche 10y agoOCaml has GIL, is normally single core, and shares no state, so current OCaml doesn't need to provide such guarantees. Upcoming multicore OCaml will provide such guarantees through algebraic effects [0]. 0. http://kcsrk.info/ocaml/multicore/2015/05/20/effects-multicore/ http://kcsrk.info/ocaml/multicore/2015/05/20/effects-multico...
- AstralStorm 10y agoFirst, Rust does not prevent data races, just makes them pain to write. Second, Rust also prevents legitimate sharing in a bunch of cases where concurrency is not involved. (and a simple scoped allocator succeeds) This would be fixed if there was an easy way to have typed memory that can be shared but cannot be accessed concurrently. There is none. You get at most full unsafe.
- steveklabnik 10y agoRust does prevent data races, as long as you don't use unsafe. If not, it's a bug. You can write arenas in Rust.
- GolDDranks 10y agoJust to be clear about the terminology (since I'm not sure if the grandparent knows about the difference): Rust prevents data races but not race conditions (although it makes it easier to avoid them). Here's an explanation about the differences: http://blog.regehr.org/archives/490 http://blog.regehr.org/archives/490
- AstralStorm 10y agoYou can, but it is an extreme pain to do it, especially for any nontrivial data structure. That is because even if the arena is safe enough, say with copy on write semantics, you cannot specify that for the borrow checker easily (or at all) You cannot implement many data structures in a decent performance way without unsafe, so Rust guarantee is weak.
- dbaupp 10y ago> You can, but it is an extreme pain to do it, It is not extreme, and it isn't even necessary: just reuse one of the many arenas others have already written, e.g. https://crates.io/crates/typed-arena https://crates.io/crates/typed-arena . Copy-on-write is fairly ease to write in Rust, e.g. the even core Rc and Arc types have a get_mut function that does copy-on-write. > You cannot implement many data structures in a decent performance way without unsafe, so Rust guarantee is weak. You can't implement anything in C or C++ without unsafe: Rust's main strength is the ability to write high performance code with a safe interface, so that only one library has to muddle through the `unsafe` problems (if they have to touch `unsafe` at all). Most code one writes is not implementing data structures. As a demonstration of this strength, even very low-level projects like operating systems can get away with not using `unsafe` everywhere by packaging it up into safe interfaces, e.g. http://os.phil-opp.com/modifying-page-tables.html http://os.phil-opp.com/modifying-page-tables.html