R
Richard Herring
It's true. If you do not have the skills and the know-how to keep track
of your own objects, and manage their lifetime,
.... or if you think garbage collection is about lifetime management ...
It's true. If you do not have the skills and the know-how to keep track
of your own objects, and manage their lifetime,
And you'll be even more professionally irresponsible if you
use a so-called "labor saving device" as merely a crutch to
support your own lack of experience and know-how, rather than
taking the time, learning, and educating yourself on how to do
it right in the first place, instead of relying on
mis-designed spaghetti code to pull you nuts out of the fire.
In message <[email protected]>,
... or if you think garbage collection is about lifetime
management ...
Given that someone had already said "stack
overflow", I'm rather surprised that Alf missed it---he doesn't
usually miss these sort of things.
* James Kanze:
I think we rely much more on simple pattern matching (and
hence expectations and previous experience) than reasoning.
Not sure if you've read David Brin's uplift trilogy, but
there's this scene where two guys cross the wilderness and one
of them plants a lot of false evidence to convince the other
there's someone shadowing them. However, the other guy
doesn't even notice all this fake evidence, because it's so
bad, so fake, so atypical, that it doesn't even reach his
higher cognitive functions for consideration... It's
automatically filtered out, because it doesn't make sense even
at the lowest level of external input processing.
Your problems begin when your maintenance task is to port the code to aJames said:Doing it right is doing it in the most effective and
maintainable way possible. Not inventing a lot of make-work
just to be able to bill extra time.
Until a later maintainer alters the object (or one that it includes) soJames said:Of course, a lot of objects don't need any particular handling
when you're through with them. Once your analysis has
determined those, with garbage collection, you're through with
them; without, you've still got to write the code to clean up
the memory.
Richard said:... or if you think garbage collection is about lifetime management ...
Your problems begin when your maintenance task is to port the
code to a platform without GC support.....
James Kanze wrote:
Until a later maintainer alters the object (or one that it
includes) so it does require particular handling when you're
through with them. Then the fun really begins.
Let me know when you figure out why, in Java, you have to
throw all these try/catch blocks around, every time you need
to deal with files or sockets,
in order not to run out of available file descriptors.
True, but there's plenty of embedded platforms with POSIX support whereJames said:Or to a platform without C++ support... Or in my case, to a
platform without directories, or sockets, or files, or threads.
GC support is at least as widely available as threads or
sockets.
My point, which appears to have been badly made, is that it is foolhardyJames said:How is garbage collection in any way relevant to that? Garbage
collection is concerned with memory management, not object
lifetime management. If you have to do something special when
an object's lifetime ends, then you have to do it. Garbage
collection or not. All garbage collection does is mean that you
don't have to worry about freeing the memory under the object,
and that you can implement code to catch errors in your lifetime
management---pointers to the object that are used after the
object is dead.
Make that "*not* acceptable!Ian said:True, but there's plenty of embedded platforms with POSIX support where
garbage collection, even if available, would be acceptable.
James said:Because Java doesn't have local objects or destructors. Which
has nothing to do with garbage collection.
In Java, you use try/catch blocks, and in C++, you use
destructors.
Garbage collection has nothing to do with the
issue.
James said:How is garbage collection in any way relevant to that? Garbage
collection is concerned with memory management, not object
lifetime management.
If you have to do something special when
an object's lifetime ends, then you have to do it.
Garbage
collection or not.
If you separate the object destruction phase from the memory release
phase, then you must be asserting that you are going to be explicitly
invoking the object destruction phase, at some point, yourself, instead
of relying on the garbage collector on doing that.
But if that's what you're going to do, if you are going to be destroying
your objects yourself, then what exactly are you going to gain by not
freeing the memory, right then and there, instead of leaving it to the
garbage collector to free the memory at some later, indeterminate point?
But that's not an automatic destructor in the C++ sense, is it?Sam said:Java most certainly has destructors. See java.lang.Object.finalize().
Ian said:But that's not an automatic destructor in the C++ sense, is it?
Alf said:* Sam:
Mostly that this processing can be done at otherwise idle moments, or spread
over time instead of all at once (like when deleting some dynamic data structure).
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.