In article <lc1yra6coa.fsf at gaffa.mit.edu>, Douglas Alan <nessus at mit.edu> wrote: >The fact that Python uses referencing counting for its front-line GC >has some very desirable properties. Two come immediately to mind: > > (1) Predictable destructor semantics. This is in contrast to Java, > in which destructors are useless because you don't know if and > when they will ever be called. I mostly disagree. If the timing of destructor calls was really predictable, you'd just call them yourself instead of depending on the GC to do it for you. If you know you're done with a file, for example, you can close it; if no part of your program knows when to close it (because more than one part of your program is using it, and they stop using it in an indeterminate order) then you don't really know when the destructor will be called, either. It *is* more deterministic than a real GC, but it's still a long way from "predictable" by my lights. > (2) No long GC pauses. Again, I mostly disagree. You get long GC pauses when the last reference to any large, complex data structure (or a data structure with slow destructors) gets overwritten or goes out of scope. >You might be able to make a "real garbage collector" that has these >properties, but it would, I believe, be pretty complicated. You can't even make a reference-counting GC that has these properties --- you need C++-style (Limbo-style?) auto_ptrs. >Since referencing-counting typically gets rid of 99.9% of all garbage, Reference-counting typically gets rid of 100% of all garbage. But sometimes it gets rid of 0% of all garbage, or (more often) somewhere in between. Which garbage it will actually collect is a global property of your program and cannot always be deduced from looking at the code that handles that garbage. >backing it up with a simple mark & sweep GC seems adequate for most >purposes. Reference-counting exacts very heavy performance costs, no matter what you back it up with. -- <kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/> Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4