News for hackers. Stuff that matters.
Re:Linus Torvalds on Garbage Collection (2002) by ondrasej on Friday April 22, 2011 @12:06PM (#2474476)
Actually, geting reference counting right and mostly bug-free is much easier, if you use C++ and do the counting via objects on stack (RAII).
Re:Linus Torvalds on Garbage Collection (2002) by VeXocide on Friday April 22, 2011 @12:17PM (#2474508)
Absolutely not, http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1450.ht... explains why in section D. Implementation difficulty
Re:Linus Torvalds on Garbage Collection (2002) by pjkundert on Friday April 22, 2011 @02:30PM (#2474945)
Actually, yes. The boost::smart_ptr<...> is highly effective. Prior to that existing, I wrote a similar ref-counting library that has been deployed to hundreds of remote sites, running high-reliability industrial control code.

While complex, the ref-counting implementation gave me something that a GC system just can't deliver:

Determinism.

This system is running on a 300MHz embedded x86 hosts, in a solid-state industrial computer, and has to provide sub-millisecond timing with only occasional hiccups >1ms acceptable. I am unaware of a GC system that could deliver this.

These boxes run for years, with no memory leaks. The cost was, of course, ensuring that no "loops" of objects get created. This was a small price to pay for the benefits. Having written large systems using both GC and ref-counting, I still lean toward ref-counting, even if determinism isn't a strong requirement.

Of course, I'm one of those guys who loves C++, so take my opinions with a grain of salt...

Re:Linus Torvalds on Garbage Collection (2002) by skorgu on Friday April 22, 2011 @05:07PM (#2475446)
IBM's Metronome[1] advertises maximum pause times in the hundreds of microseconds range. Cliff Click[2] cites a 10MB max heap for it so definitely not a cure-all but definitely something I'd like to play around with.

[1]http://domino.watson.ibm.com/comm/research_projects.nsf/page... [2]http://www.youtube.com/watch?v=uL2D3qzHtqY

Re:Linus Torvalds on Garbage Collection (2002) by FooBarWidget on Saturday April 23, 2011 @04:15AM (#2476490)
Reference counting is not deterministic. Whenever a refcount is lowered to 0, you don't know how many subsequent references exist further up the chain that will also be lowered to 0. Lowering a refcount to 0 can result in an arbitrary amount of code to be executed depending on the references.

If you mean that reference counting, on average, tends to result in fewer amounts of random/unpredictable pauses than most GCs, then I agree.

Re:Linus Torvalds on Garbage Collection (2002) by z92 on Saturday April 23, 2011 @09:53AM (#2476813)
I guess on that scale and probability, no code is deterministic.
Re:Linus Torvalds on Garbage Collection (2002) by rtaycher on Saturday April 23, 2011 @07:08AM (#2476642)
reference counting is slower* then other forms of gc. My guess why its fairly fast in c++ has a lot to do whith how much you can avoid it by allocating things on the stack(of course you can do escape anaylsis but most gc'd languages don't have explicit stack allocation of non basic types)

*with a lot of collaries

Re:Linus Torvalds on Garbage Collection (2002) by marshray on Friday April 22, 2011 @02:46PM (#2474996)
I, too, love C++ and the boost smart pointer library.

In fact, it's been adopted into modern versions of the C++ standard itself. std::tr1::shared_ptr and std::shared_ptr.