Pete said:
You're the one making the claim, not me. The fact that you decline to cite
evidence supporting your claim makes it highly suspect.
1. If memory management is handled by the compiler and runtime environment,
it can perform hybrid optimisations:
http://lists.tunes.org/archives/gclist/1997-November/001291.html
2. Retrofitting a GC alters the semantics of the language and makes
languages like C++ even less safe and even more error-prone unless you
manage the whole language, in which case performance suffers terribly:
http://gcc.gnu.org/ml/java/1999-q4/msg00467.html
3. Run-time representation can be tuned for GC if the language was designed
for GC, e.g. tagging vs boxing.
http://pauillac.inria.fr/~xleroy/talks/compilation-agay.pdf
4. Language implementors can choose to use stack or heap if the language is
designed for GC.
http://citeseer.ist.psu.edu/11526.html
5. A retrofitted GC cannot move objects to compact the heap, i.e. it will
never be as space-efficient as a real GC.
"Many Java/ML/Scheme implementations have faster garbage collectors that may
move objects..." - Hans Boehm
http://www.hpl.hp.com/personal/Hans_Boehm/gc/nonmoving/html/slide_4.html
6. Conservative garbage collectors try to make the best of a bad job by
guessing which heap values are pointers.
Look at Boehm's own GC benchmark:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_bench/
"Some Java implementations have similar or better performance"
Running Boehm's own benchmark here, Java is as fast as C++ without GC and
twice as fast as C++ with Boehm's GC:
$ g++ -DGC -lgc -O2 GCBench.cpp -o GCBench
$ time ./GCBench
....
real 0m1.975s
user 0m1.604s
sys 0m0.356s
$ javac GCBench.java
$ java GCBench
....
real 0m0.982s
user 0m1.008s
sys 0m0.120s
This is primarily due to the fundamental limitations of retrofitting a GC
onto C++, as Boehm himself described.
Huh? How in the world does porting some simple program from some other
language to C++ show that some things "will never work as well as a
system designed for them"?
I've led you to water...