Why does D rely on a GC?
maik klein via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 18 12:43:13 PDT 2014
On Monday, 18 August 2014 at 18:56:42 UTC, b wrote:
> With RC you pay a price during creation/deletion/sharing, ...
Are you sure that there is even a cost for creation? I mean sure
we have to allocate memory on the heap but the GC has to do the
same thing.
And with C++11 unique_ptr moves by default, so I think that the
creation cost is exactly the same as with a GC.
I also think that deletion is cheaper for a unique_ptr compared
to a GC, because all you have to do is call the destructor when
it goes out of scope.
My initial question was why D uses the GC for everything.
Personally it would make more sense to me if D would use the GC
as a library. Let the user decide what he wants, something like
shared_ptr(GC) ptr;
shared_ptr(RC) ptr;
More information about the Digitalmars-d
mailing list