LinkedIn Article to be: Why you need to start moving off C/C++ to D, now.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 15 13:58:40 PDT 2014


On Tuesday, 15 July 2014 at 20:03:15 UTC, Chris wrote:
> From the link above:
>
> "It’s a common but false belief that reference counting (using 
> shared pointers in particular) is better than garbage 
> collection. There is actual research* showing that the two 
> approaches are just two sides of the same coin. You should 
> realize that deleting a shared pointer may lead to an arbitrary 
> long pause in program execution, with similar performance 
> characteristics as a garbage sweep. It’s not only because every 
> serious reference counting algorithm must be able to deal with 
> cycles, but also because every time a reference count goes to 
> zero on a piece of data a whole graph of pointers reachable 
> from that object has to be traversed. A data structure built 
> with shared pointers might take a long time to delete and, 
> except for simple cases, you’ll never know which shared pointer 
> will go out of scope last and trigger it."
>
> * http://www.cs.virginia.edu/~cs415/reading/bacon-garbage.pdf

Yes but D's GC is crap. I actually wanted to a a quick hack in it
recently to avoid going through the lock every time for every
operation, but ended up giving up. Also the API between the GC
and the compiler need to be reworked.

Finally someone posted here a research paper from ibm if memory
serve. It show that ref counting is a win for single threaded
code, but is a net loose when sharing across thread, because of
the synchronization overhead (especially the hammering of the
cache line containing the reference count).


More information about the Digitalmars-d mailing list