Settings

Theme

Garbage collection is contrarian

trynova.dev

68 points by aapoalas 23 days ago · 24 comments

Reader

kannanvijayan 20 days ago

Writing a GC in rust without just dropping the whole business into unsafe is really annoying.

Jason Orendorff has an implementation of a GC in rust called "cell-gc" that seemed like only one I've seen so far that seemed to "get" how to marry rust to the requirements of a GC implementation: https://github.com/jorendorff/cell-gc

Still has a lot of unsafe code and macro helpers, but it's laid out well and documented pretty well. Not sure if you've run across it yet.

eru 21 days ago

Compare also 'A Unified Theory of Garbage Collection' https://web.eecs.umich.edu/~weimerw/2008-415/reading/bacon-g...

shevy-java 20 days ago

This reminds me of the old Monty Python sketch:

https://www.youtube.com/watch?v=uLlv_aZjHXc (Argument Clinic)

antonvs 21 days ago

Just intuitively, this seems to be using a feature designed to guarantee safety in a way that doesn’t guarantee safety, which raises questions about what the point is.

  • aapoalasOP 20 days ago

    Author here: to get the compiler to help me as the programmer to produce correct code (not accidentally using handles after GC) without being massively manual, but (at least currently) accepting that it is not a guarantee and thus runtime checks (bounds checks in my case) are needed to retain memory safety.

anArbitraryOne 20 days ago

I clicked on this hoping is was about physical garbage collection

_3u10 21 days ago

Just use unsafe then you have all of the good points of rust, like being able to say you wrote it in rust with none of the downsides, like having to write safe code in rust, or that code being slow.

illuminator83 20 days ago

I'm hoping for a future in which humankind looks back with embarrassment at this silly period in its history in which people used to think a leaky and bad abstractions like garbage collection was ever a good approach to deal with resource life-times.

  • aziis98 20 days ago

    Still the whole world runs on GC-ed languages so it must be an abstraction at least some people like to work with.

    And I'm pretty sure using a GC in some cases it's the only option to not go crazy.

    • illuminator83 20 days ago

      I think we are just used to it. Like we are used to so many suboptimal solutions in our professional and personal lives.

      I mean, look something like C++ or the name "std::vector" specifically. There are probably 4 Trillion LoC containing this code out there - in production. I'm used to it, doesn't make it good.

  • aapoalasOP 20 days ago

    Monkey's paw: you get your wish, but so does someone who wants RAII and single-use-malloc to be left behind as a leaky and bad abstractions.

    We all happily march into a future where only arena allocation is allowed, and when the arena is overfull it can only be fully reset without saving data. Copying still-used data out if it before reset is not allowed, as that's a copying half-space garbage collector. Reference counting is of course not allowed either as that's also garbage collection. Everyone is blessed...?

  • zahlman 20 days ago

    Some problems are just fundamentally easier to solve using cyclic data structures whose lifetime exceeds the scope where they were created, which would be quite difficult to clean up properly in any other way.

  • AllegedAlec 19 days ago

    Indeed. I also hope we stop using all of these "high-level" languages. So much overhead just so people don't have to learn how to write proper optimized machine code. It's super-trivial to write a website directly in that too, and it only takes a bit longer, but it is almost twice as fast.

    • illuminator83 18 days ago

      I'm a big fan of high-level languages and abstractions. I'm just not a fan of bad abstractions.

  • immibis 20 days ago

    Did you know the Linux kernel has a tracing garbage collector in it, specifically for Unix socket handles? It seems to be a recurring solution to a common problem.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection