4 ms·
> But come at rust with a use case (cyclic data structures here) for which it's a poor fit I'm not even disagreeing in general that Java is likely to be better
by creata 1y ago
> But come at rust with a use case (cyclic data structures here) for which it's a poor fit
I'm not even disagreeing in general that Java is likely to be better for most problems. But the options in Rust for cyclic data are actually fine:
* You can use integer indices into an array instead of pointers.
* You can use unsafe and raw pointers, and be in the exact same situation as C++. The doubly linked list in the standard library is a cyclic data structure does that.[1]
* You can use reference counting (std::rc)[0]. This is literally a garbage collector in the standard library, equivalent to C++'s std::shared_ptr.
These are all simple. None of them is as complicated as "write your own GC".
[0]: https://doc.rust-lang.org/stable/std/rc/ https://doc.rust-lang.org/stable/std/rc/
[1]: https://doc.rust-lang.org/std/collections/struct.LinkedList.html https://doc.rust-lang.org/std/collections/struct.LinkedList....