3 ms·
I've often wondered what it would be like having a variant of Rust that was essentially the same underlying language, but with a garbage collector of some kind
by dvlsg 4y ago
I've often wondered what it would be like having a variant of Rust that was essentially the same underlying language, but with a garbage collector of some kind instead of a borrow checker and lifetime annotations.
- gary17the 4y agoYou can approximate this already: forget Rust references (borrow checking + lifetimes; in other words, raw pointers) and start hacking with Rust using its shared ownership (reference-counted) smart pointers, immutable Rc<T>[1], mutable RefCell<T>[2] and the combination of the two[3]. The syntax will, overall, get considerably more dense than Go, but otherwise analogous to Go. Instead of GC cycles, memory will be freed incrementally, immediately when no longer in use. [1] - https://doc.rust-lang.org/book/ch15-04-rc.html https://doc.rust-lang.org/book/ch15-04-rc.html [2] - https://doc.rust-lang.org/book/ch15-05-interior-mutability.html https://doc.rust-lang.org/book/ch15-05-interior-mutability.h... [3] - https://doc.rust-lang.org/book/ch15-05-interior-mutability.html#having-multiple-owners-of-mutable-data-by-combining-rct-and-refcellt https://doc.rust-lang.org/book/ch15-05-interior-mutability.h...
- duped 4y agoThat would be pretty close to OCaml.
- dvlsg 4y agoThat's fair. My favorite language so far has been F#, so maybe it's some of that preference sneaking through.