What's the go with the GC these days?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jan 7 22:29:46 UTC 2019


On Mon, Jan 07, 2019 at 10:02:02PM +0000, Guillaume Piolat via Digitalmars-d wrote:
> On Monday, 7 January 2019 at 18:18:05 UTC, H. S. Teoh wrote:
> > Yep. GC phobia is a common malady among C/C++ folks (I used to be
> > one of them).
> 
> Guilty as charge here!

I wonder if some of us ex-GC-phobists(?) should throw together a D blog
entry with brief summaries / excerpts of how we got over our GC phobia
and came to embrace the GC.  Could be a useful way to collect some
common GC myths / arguments for GC in a place where we can point people
to.


> What I like most about GC is the efficiency! With scanning and a
> global owner, you don't need to keep ownership information anywhere.

That's true!

And also, having a dedicated collection thread also means you get better
cache coherency and economy of scale, as opposed to individually freeing
small objects here and there and incurring many RAM roundtrips.


> Which leads to less copying (std::string leads malloc for every string
> copy, GC avoids that), slices being two machine words instead of 3,
> etc.

Yeah, std::string copy-on-assign and copy-on-substring do add a lot of
overhead that people are often unaware of.  Well, some people *are*
aware of it, but the "solution" many adopt is to avoid std::* and go
back to the bad ole world of char* and buffer overrun heaven.  Both are
pessimal.  D's slices r0x0rs.


T

-- 
Too many people have open minds but closed eyes.


More information about the Digitalmars-d mailing list