5 ms·
This is nice. But I'm wondering, why do garbage collectors always have to be written from scratch for each project? Why can't we just have a library that does g
by amelius 12y ago
This is nice. But I'm wondering, why do garbage collectors always have to be written from scratch for each project? Why can't we just have a library that does garbage collection, and does it well?
Of course, the library should take a couple of parameters (such as the primitives to use for memory barriers, multithreading parameters etc.) I know of the Boehm collector, but it is conservative, so not appropriate for many projects.
Also, I'd expect to find garbage collection (or supporting constructs) in the C++ standard by now, actually.
- chrisseaton 12y agoYou say the library should take a couple parameters, such as the primitive to use for memory barriers - but the memory barriers are something the GC would need to tell the compiler about, not the other way around. So your library needs to know about how your compiler works, and it's no longer really a library, it's now a language feature that needs to tie into the most intimate parts of your compiler's intermediate representation. That's why you don't get libprecisegc.o.
- amelius 12y agoYes, I agree that there should be cooperation between the library and the compiler. But that is also the case for RAII, for example, where the compiler provides the primitives (through language design, e.g., constructors, destructors, copy constructors, etc.) which allow it to work. I'm just wondering why no such thing exists for garbage collection (yes, I'm aware that the interface would be much more complicated).