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

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 15 14:29:35 PDT 2014


On Tue, Jul 15, 2014 at 09:19:27PM +0000, John Colvin via Digitalmars-d wrote:
> On Tuesday, 15 July 2014 at 21:13:22 UTC, Paulo Pinto wrote:
> >Am 15.07.2014 22:58, schrieb deadalnix:
> >>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.
> >
> >Which boils down to having to improve the GC implementation, not that
> >GC in general is bad.
> 
> Perhaps we should stop calling it a "Garbage Collector" and call it
> "Fully Lazy Snapshot Reference Counting" instead :)

+1. :D

It does make one wonder, though, and the paper does briefly discuss this
topic at the end, if there exists a "sweet spot" in the design space
where you can get the benefits of both approaches and minimize their
weakness of each. Or whether there exists a kind of "universal"
collection algorithm with knobs that, if tuned to one extreme, behaves
like a GC, and if tuned to the other extreme, behaves like an RC. In an
ideal world, if such a universal implementation exists, then you could
in theory fine-tune it precisely to your specific application's needs.


T

-- 
Being able to learn is a great learning; being able to unlearn is a greater learning.


More information about the Digitalmars-d mailing list