Pardon for jumping in...
Jeffrey Schwab said:
The languages are garbage-collected, but the implementations are not.
Even Java's implementation is written in C++. Nobody's saying his
functional language shouldn't have GC.
Right. Machine code is not garbage collected, and there exist garbage
collected interpreted languages, ergo it is possible to implement a
garbage collected language interpreter in a non-collected language.
That doesn't mean it is easy. In fact, I will go ahead and assert,
without explicit evidence, that it is among the most difficult things to
do well, throughout all of software development. I feel comfortable
asserting this because I've done it, and I've done most other things,
and I can compare my experience in the two.
There are ways to make it easier, of course. You can give up on certain
performance implementation techniques, for example by sticking with a
single kind of collector, and avoiding generational implementation. You
can give up on correct implementation and document the deficiencies, as
happens with both conservative collectors and practically all reference
counting implementations. But then you have to deal with the
deficiencies, and it's still not exactly easy unless you go the ref-
counting route.
Right, because he thinks he needs it. My point was that he might not,
and that he probably shouldn't choose his language based on the presence
of absence of GC.
I'd definitely think that if one can save perhaps six months of hard
development work, and get a first-class garbage collector in the
bargain, by choosing a certain implementation language, then that's a
pretty decent reason for the decision. Perhaps there are other factors
that would outweigh that advantage, but they'd have to be pretty big
factors.
C++ does not lack memory management. Please stop implying otherwise.
It's getting irritating.
C++ certainly lacks automatic memory management, resulting in
programmers doing a lot of the work that would be considered memory
management in a garbage collected language. You can be as picky as you
like about the words; but there's something being said there whether you
like the wording or not. Feel free to propose new wording, and I'm sure
people will be happy to consider it.
No, it's as local as it needs to be.
If we're talking about memory management at the C++ level, the language
specification makes it well-nigh impossible to provide a real garbage-
collected implementation of C++. The culprit is that there's too much
specified behavior involving memory layout and pointers. If more of
that kind of thing resulted in undefined behavior, then it may be
possible to provide a garbage-collected implementation; but that's not
the case.
Of course, none of that applies to the target interpreted language; but
you certainly can't push memory management back onto the C++ manual heap
in the same way you can in Java or any other garbage collected language.
A reasonable-performance garbage collector would require that the
interpreter allocate large blocks of memory for itself, probably using a
system call like sbrk rather than any C++ language concept, and then
provide its own memory management with that. Memory that's used by the
interpreted language could not be allocated from the standard C++ heap,
whereas that could easily be done in Java.
Rather than pan the performance on theoretical grounds, you
might want to get some numbers from the real world.
If you're referring to the statement that reference counting would yield
poor performance, that is well-documented enough throughout the gc
literature that there's no reason to ask anyone to test it yet again
every time they want to make the claim.
Have you seriously had a problem with GC in Python? They're not
"half-arsed" implementations.
I haven't used Python enough to know whether the problems are serious or
not. From reading documentation, though, it appears Python has a
correct garbage collector with poorer than needed performance. That may
be fine for many applications, and not for others. It also appears to
have taken them a while to finish (they had a broken garbage collector
until version 2.0). It doesn't appear to be buggy.
That being said, though, Python is a pretty big project with a lot of
developers. Things that are feasible for Python are not necessarily
feasible in other contexts. (Actually, I'm surprised that Python
doesn't have a better collector by now -- one that combines different GC
techniques according to what's best for the specific generation -- but I
suppose there may be enough overhead elsewhere that gc overhead doesn't
matter so much.
We disagree again. You've effectively said that a certain type of GC is
critical, but that only Java (and I assume you acknowledge C#) provides
it. I say that deterministic destruction is a reasonable alternative.
While being careful not to speak for Chris Uppal, I'd suggest it's very
likely that when he talks about a real garbage collector, he means one
that:
(a) doesn't sacrifice performance unnecessarily
(b) is correct (not conservative, collects all garbages)
Garbage collectors that provide deterministic destruction are okay for
very limited applications, but they have performance disadvantages that
prevent their being used for most applications. In most cases where
deterministic destruction is needed, the application should not be
implemented with a garbage collected heap at all.
The fact that C++ has better support for it than other languages does
not mean the language is more restrictive.
If you mean that a non-garbage collected language such as C++ is
sufficient for general purpose scripting, then you are somewhat outside
of the mainstream, and near-universal practice disagrees with you.
I think we're viewing the world from very different angles. Determining
the hierarchy ownership has proven one of the most valuable techniques
at my disposal.
It is provable (see work by Hans Boehm) that there are problems for
which solutions satisfying the need for an explicit free operation
require asymptotically greater running time than the equivalent
implementation in a deferred garbage collector. It is also provable
(see Andrew Appel) that the same is not true in the other direction.
This is not a matter of perspective. If you find assigning ownership
helpful to your design, you may continue to do it in any language; but
not needing to do so when it makes efficient solutions impossible is
objectively beneficial.
It sounds like only Java has a GC you approve, ergo you consider only
Java a "real" general-purpose language. I suppose you might make an
allowance for C#.
Huh? You are reading something into Chris's responses that isn't
actually there.