5 ms·
So this leads to the question: Why there isn't an open-source garbage collector that can be used across different projects? Surely Python, V8, and Ruby have en
by astrodust 13y ago
So this leads to the question: Why there isn't an open-source garbage collector that can be used across different projects?
Surely Python, V8, and Ruby have enough in common, allocation-wise, that the code can be shared? They're all C in the back-end. It's just pointers and more pointers at the lowest level.
It's not about making a toy GC, it's about making a top-rate GC that works and packaging it up as a tool.
- Derander 13y agoTo a certain extent that's what the JVM is -- you just have to target its bytecode :-).
- astrodust 13y agoThat's not exactly a portable back-end toolkit you can just link in.
- Tuna-Fish 13y agoIt's not really possible to do that with GC. It requires analyzing and dealing with basically every assumption about object lifetimes that is done within the system, and that typically requires you to read and understand every single line of code. I have worked on GC projects, and imho bolting on a good GC system on an existing language runtime is considerably harder than reimplementing the entire runtime on top of a GC platform.
- __alexs 13y agoThe Boehm GC [1] has been integrated with various other languages in the past. I'm aware of various attempts to get both Python and Ruby code running with it. 1. http://www.hpl.hp.com/personal/Hans_Boehm/gc/ http://www.hpl.hp.com/personal/Hans_Boehm/gc/
- silentbicycle 13y agoGarbage collection is a particularly cross-cutting implementation issue, and tends to interfere with all kinds of abstraction. You're essentially making a system that knows which specific ways abstraction can be broken safely, so that you can defer resource management to it in the future. Retrofitting a GC is even harder. You can bolt on a conservative collector (like boehm-gc), sure, but that can lead to many unexpected performance issues (see e.g. http://timetobleed.com/6-line-eventmachine-bugfix-2x-faster-gc-1300-requestssec/ http://timetobleed.com/6-line-eventmachine-bugfix-2x-faster-...). Writing a virtual machine for a GC'd language and then trying to give it a portable, reasonably convenient C API convinced me that it's a significantly harder issue than most people realize. (Particularly after scrapping my third prototype!) The C API also impacts many things, and tends to bring up nasty edge cases in the GC. Lua seems to have settled on a design that works unusually well, and is worth studying. Still, Lua can safely cut corners that Python and Ruby cannot - they have threads, which also break a lot of assumptions.