What's the go with the GC these days?

Manu turkeyman at gmail.com
Sun Jan 6 07:48:03 UTC 2019


On Sat, Jan 5, 2019 at 7:45 PM Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 1/5/2019 2:05 PM, Manu wrote:
> > How much truth is in here?
>
> There's a lot of triggering on the word "GC". At some level, it doesn't matter
> how good or bad the GC is, it's "GC is bad". Even if your code never calls the GC.
>
>
> > What is this business about write barriers making the GC fast? Is that
> > actually fact, or are there other hurdles?
>
> Here's an explanation:
>
> https://stackoverflow.com/questions/19154607/how-actually-card-table-and-writer-barrier-works
>
> There are many more if you google "gc write barrier".
>
> The penalty, of course, is extra code gets run for every write through a pointer.
>
> The benefits exceed the penalties for a language where all dynamic allocation is
> done via the GC. But for D, where quite a lot of it is not, it isn't so clear.
> What is clear is that if you're going to compare speed with C++, having those
> write barriers in there is going to be a serious penalty, because they'll be
> there even if you don't use the GC.
>
>  > Where's the ARC stuff? What happened to opAddRef/opRelease?
>
> Andrei, Razvan, and I have decided that the most pragmatic way forward to
> support reference counting is to support copy constructors ala C++. C++ is
> clearly successful with this approach, and Andrei/Razvan concluded that D's
> postblit just doesn't cut it. Razvan has a proposal for copy constructors, and
> an implementation PR that has fallen a bit behind his latest proposal.

Hmnm, that's pretty disappointing... as a C++ user who has been doing
C++ ref counting for years, I would say that, while maybe it is
*kinda* successful, it's not at all satisfying, and it's one major
reason I've been pushing it in D for the last 8-9 years.
Ref counting in C++ is a sloppy hack. I really just want the compiler
to emit opInc and opDec appropriately on either sides of a reference
assignment, and let me take it from there.
Also, with escape analysis, we can elide such calls very effectively,
and we can't do that using the C++ strategy.

I think it's disappointing to embrace C++'s hacky 'solution', we could
do better.


More information about the Digitalmars-d mailing list