Linus with some good observations on garbage collection

Francisco Almeida francisco.m.almeida at gmail.com
Sun Apr 24 14:57:29 PDT 2011


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> Andrei:
> > It might not a good use of our time to further engage in a diatribe on this.
> Just a note: you have not wasted your time discussing this, because I am not
expert on such matters, so I learn something from informed discussions :-)
> If a book that explains C language is just 200 pages long, a book that explains
the design purpose, design constraints and design compromises of every feature of
C language requires a much longer book (800 pages?), and it's probably also much
more interesting :-)
> Bye,
> bearophile

As one of those who were the most reluctant about abandoning delete, I have come
to realize that it is better to make D classes strictly garbage collected, and
drop delete.

It should be noted that D supports RAII, as long as one uses struct (thus avoiding
dynamic polymorphism, which shouldn't make a big difference once you think about
it), and this gives D an important semantic separation lacking in C++ (or even
those languages on the other side of the fence such as Java, for that matter).

Making a habit of declaring struct instead of class when I intend to create
"objects" on the stack instead of the heap, while resorting to garbage collected
classes when it makes sense to do so, has made my life simpler.

I do believe, however, that there is a recurrent communication error going on here.

I would kindly ask the language designers to please update the documentation and
write an article explaining the advantages of the approach (without making the
mistake of turning it into a blind praise of garbage collection, that is).
Newcomers need to know how to obtain garbage collected or RAII data structures
from D, whenever they want to.


More information about the Digitalmars-d mailing list