4 ms·
The primary reason they stated is memory safety as this is gonna be really critical stuff dealing with money. Also no GC.
by vijaybritto 7y ago
The primary reason they stated is memory safety as this is gonna be really critical stuff dealing with money. Also no GC.
- tomp 7y agoOCaml is more memory safe than Rust (as the "unsafe" parts are harder to access). But it does have GC, so GC is likely the primary reason.
- gfs 7y agoI wouldn't label Rust as being less safe than OCaml. You have to explicitly opt-in to any unsafe operations. More often than not, the unsafe blocks are needed because the compiler can not check all of the invariant cases.
- saagarjha 7y agoDoes OCaml even have a way of shedding memory safety?
- ncmncm 7y agoOCaml is an "obligate-GC" language. Most languages that offer optional GC, including Rust (with its RC and ARC boxing) and C++ (with std::shared_ptr), implement it mainly via reference-counting.
- tomp 7y agoYes, the `Unsafe` module (well, at least used to have it... fairly undocumented... maybe it's been removed?).
- tomp 7y agoOops, I misremembered the name. @pcwalton is right, it's called `Obj`.
- pcwalton 7y agoSure. Obj.magic is a bit cast.
- ori_b 7y ago> You have to explicitly opt-in to any unsafe operations Many of the unsafe operations don't exist in OCaml. Often because the GC makes them unnecessary.
- pcwalton 7y agoYou can implement all of the unsafe operations in OCaml using the unsafe Obj.magic cast: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Obj.html http://caml.inria.fr/pub/docs/manual-ocaml/libref/Obj.html
- pcwalton 7y agoI mean, you can just use #[forbid(unsafe_code)] if you really want to. You do have to audit your dependencies, but that's true with OCaml as well (call Obj.magic and all bets are off).