Why does D rely on a GC?
maik klein via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 18 03:01:57 PDT 2014
First of all I don't want to insult anyone on language design, I
just want to know the reason behind the "always on" GC.
I know that the GC as several advantages over reference counting,
especially when it comes to immutable data structures.
What I don't (correct me if i am wrong) understand is why every
heap allocation has to be garbage collected, like classes,
dynamic arrays etc.
Does a GC still have advantages over heap allocations that do not
need to be reference counted such as the unique_ptr in c++?
The dlang homepage stats:
Destructors are used to deallocate resources acquired by an
object. For most classes, this resource is allocated memory. With
garbage collection, most destructors then become empty and can be
discarded entirely.
If I understand it correctly it means that D has a GC, so most
classes don't need a destructor anymore because they don't need
to do any cleanup. I am not totally convinced that this would be
a good trade off in general. Maybe someone could shine some light
on this statement?
More information about the Digitalmars-d
mailing list