3 ms·
> GC can be treated like a backstop which helps to keep your application from exploding while you work on memory management, and then you can incrementally addr
by zozbot234 6y ago
> GC can be treated like a backstop which helps to keep your application from exploding while you work on memory management, and then you can incrementally address heap alloc (aka latency) concerns with an application that actually runs (for a little while at least).
This is not a good approach in general. GC is only really needed in applications when working with data that's graph-like and potentially involves cycles of object references. A software project should be properly designed at the outset so that GC can be used in a "pluggable" way where it's strictly needed. Rust will probably enable this kind of use in the future, but other languages such as Go can already be used to comparable effect, seeing as they're generally limited to smaller pieces of code ("microservices") running in their own separate address space.
- jzoch 6y agoThere are already a couple gc libraries in rust. I wouldnt say Go is strictly "pluggable gc" since...well you can't get rid of the gc. You can try and keep it from doing meaningful work but thats quite different than "RAII managed memory with a fallback to a gc library that targets my particular use-case" Fully agree with you that GC should be abstracted away and used for where it shines: cycles and graphs!
- lumost 6y agoThere was some consideration for a formal library based rust GC back in 2018 such that one could write GC<CyclicDataType> and get the benefits of a GC such as - Not leaking memory - Not invoking unsafe - Not angering the rust compiler None of those efforts stabilized to my knowledge, and the libraries developed for this task all have experimental/research tags associated to them. For better or worse all the guides for using rust strongly encourage avoidance of primitive cyclic structures such as doubly linked lists, graphs, and other structures in favor of statically allocated fixed size variants. Like golang's preference for map/list as the only primitive structures, this is a constraint that one can get used to for most problems. But it doesn't feel great that as a language there are basic algorithms and datastructures that can't be idiomatically coded in the language.
- steveklabnik 6y agoThere’s a new GC library released the other day https://blog.typingtheory.com/shredder-garbage-collection-as-a-library-for-rust/ https://blog.typingtheory.com/shredder-garbage-collection-as... Still extremely new, of course, but has promise!
- deleted 6y ago[deleted]
- gameswithgo 6y agoYou can already use reference counting when needed. Pretty close to what you are envisioning.