Re: Garbage Collection - The Trash Begins To Pile Up
Carlos Moreno wrote:
Francis Glassborow wrote:
I do not use exceptions for everything (and routinely remind attendees
at course I present that exceptions only add another mechanism for
dealing with problems, they do not replace the others.
Many of the recognized "C++ authorities" would disagree with this ---
or, to avoid putting words in their mouths, let's say that statements
from those C++ authorities seem to disagree with the above.
From Exceptional C++:
"It's pretty near impossible to write robust code in modern C++ without
knowing about exception safety issues. Period"
How does this disagree with what Francis said?
From More Effective C++:
"The addition of exceptions to C++ changes things. Profoundly.
Radically. Possibly uncomfortably. [...] It becomes more difficult
to write constructors and destructors that behave the way we want
them to"
How does this disagree with what Francis said?
And the exceptions mechanism seems to me *a lot* less interconnected
to the rest of the language features than GC would be.
Why? I'd say just the opposite: garbage collection only affects
the code which uses it. Just one exception from a low level
function, and you're entire code base must be made exception
safe.
OTOH, exceptions provide a solution for a problem that really did not
have a *valid* solution --- setjmp and longjmp are such an atrocity
that I assume no-one would want to even consider them as candidates
to be a solution. Twisting the code ad-infinitum with error-code
verifications is not a *valid* solution either.
Nor is manual memory management.
In fact, of course, people were writing correct programs long
before exceptions came along, just as people are writing correct
programs today without garbage collection. I'd even go so far
as to say that if your organization is not capable of producing
correct code without exceptions/garbage collection, it won't be
with them. You either know how to address the issues, or you
don't. Both exceptions and garbage collection, however, provide
a powerful tool for solving an important subset of the problem
with a lot less work: you can write correct code with or
without, but the cost of doing so is a lot higher without.
GC replaces something for which we already have solutions --- and
in the process, radically changes the face of the language and
possibly invalidates a scarily large fraction of existing code.
I think you've got it backwards. The introduction of exceptions
pratically broke most existing code; garbage collection doesn't
change anything with regards to existing code (or very, very
little---it will break code which hides pointers).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientie objet/
Beratung in objektorientierter Datenverarbeitung
9 place Simard, 78210 St.-Cyr-l'Icole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]