News for hackers. Stuff that matters.
Re:Garbage Collection is Wrong by rian on Thursday February 27, 2014 @04:45PM (#7315345)
Yes I think you would use a ref counted resource in that case. For your tangled mess of database connections I can't imagine ref counting not being adequate in those scenarios as well.
Re:Garbage Collection is Wrong by danbruc on Thursday February 27, 2014 @04:51PM (#7315392)
And now we are back at garbage collection - the two main options are reference counting GCs and collecting GCs. I know it for the .NET GC, they tried a reference counting GC and it performed worse than a collecting GC and not to forget the trouble with cycles when implementing a reference counting GC.

And reference counting also renders the point of determinism moot - now you never know if releasing a reference while trigger freeing a resource. You could of course delay offload it to a separate thread, but this makes you lose any guarantee about the time when the resource is actually freed, too.

Re:Garbage Collection is Wrong by letzjuc on Thursday February 27, 2014 @05:21PM (#7315646)
> And reference counting also renders the point of determinism moot - now you never know if releasing a reference while trigger freeing a resource.

You know that releasing the last reference will. That is why the important concept is single ownership of resources and not reference counting by itself.

Re:Garbage Collection is Wrong by danbruc on Thursday February 27, 2014 @05:35PM (#7315738)
But you don't know which reference is the last until you actually get there - that is why you used reference counting in the first place, because you were unable to statically determine which reference will be the last one. So every time you abandon a reference it might be the last one and you might have to spend extra cycles to free the resource. This is no more deterministic than a garbage collector.
Re:Garbage Collection is Wrong by letzjuc on Thursday February 27, 2014 @08:55PM (#7316753)
In a non-deterministic garbage collector memory _might not_ be released when the last reference goes out of scope (and this is often the case).
Re:Garbage Collection is Wrong by rian on Thursday February 27, 2014 @05:10PM (#7315555)
Ah, I don't think ref counting is generally considered GC. It's more like RAII and used in C++ elsewhere via shared_ptr.
Re:Garbage Collection is Wrong by danbruc on Thursday February 27, 2014 @05:31PM (#7315714)
It is a mechanism to figure out if a resource is no longer in use and can be released - that sounds like the very definition of garbage collection.