From: Robin Redeker <[EMAIL PROTECTED]> Date: Thu, 28 Apr 2005 00:12:50 +0200
On Wed, Apr 27, 2005 at 12:33:30PM -0600, Luke Palmer wrote: > I agree with Dan completely here. People make such a big fuss over > timely destruction when they don't realize that they don't really need > it. (But they want it). I think, more importantly, they don't > understand what they're getting in return for giving it up. Could you point out what i get? I use TD is to handle resources: filehandles, database handles, gui windows and all that. My idea of "timely" is RIGHT NOW for filehandles, when the program ends for DB handles, and whenever for the rest. So I don't see TD as much of a win, even if it were completely for free. But it's not; the rest of the world would have to forego entire classes of data structures in order to save the few lines of extra code you would need to manage a few of yours explicitly. This seems like a bad tradeoff. Refcounting does this with a little overhead, but in a fast and deterministic O(1) way. This is the first half of an apples-to-oranges comparison, and so is misleading even if partly true. Refcounting may be proportional (approximately) to the amount of reference manipulation, but GC is proportional (though even more approximately, and with a different constant) to the amount of memory allocated [1]. Because of this, a program that runs for a long time without allocating much additional memory incurs zero GC cost during that time; this is a clear (and even deterministic) win over refcounting. From: Dan Sugalski <[EMAIL PROTECTED]> Date: Thu, 28 Apr 2005 13:10:00 -0400 . . . >I don't think circular references are used that much. This is maybe >something a programmer still has to think a little bit about. >And if it means, that timely destruction maybe becomes slow only for the >sake of collecting circular references... don't know if thats a big >feature. Circular references are far more common than objects that truly need timely destruction, yes, and the larger your programs get the more of an issue it is. Neither are terribly common, though. I'm astounded. Do neither of you ever design data structures with symmetrical parent<->child pointers? No trees with parents? No doubly-linked lists? In my (probably skewed) experience, circular references are used frequently in languages like C or Lisp that don't penalize them. -- Bob Rogers http://rgrjr.dyndns.org/ [1] Work done by a copying GC when it runs is proportional to the amount of non-garbage copied, but that doesn't apply to Parrot, and we were talking about GC frequency in any case.