Linked by ebasconp on Fri 10th Jun 2011 22:22 UTC
Benchmarks "Google has released a research paper that suggests C++ is the best-performing programming language in the market. The internet giant implemented a compact algorithm in four languages - C++, Java, Scala and its own programming language Go - and then benchmarked results to find 'factors of difference'."
Thread beginning with comment 476969
To view parent comment, click here.
To read all comments associated with this story, please click here.
Member since:

Read the last part of the paper.

(myself) Manual delete are faster as long as the destructor is simple. You can have a pseudo fast GC my deriving all objects from a GC class and use it to increment/decrement object reference count and use a templated, inlined accessor like function instead of = or override = manually for every class (to keep the object count). Then when the ref count = 0, then delete itself.

But this is not "safe" nor complete. Real time ref analysis is slow. Static/dynamic analysis also require to keep/manage a complete list of all memory allocation, this take management time, interpreter time (for VM based language) and a lot of memory. Al least, it how I see it.

Reply Parent Score: 2

f0dder Member since:

How do you handle cyclic references with that approach? (root-tracing GC helps a lot in handling those).

How do you suspect it performs in heavily threaded code? (you need mutexing both on the refcount and on your heap).

GC isn't the end-all-be-all, but for a lot of scenarios it works very well - and it's going to be a lot of effort emulating in C++, and won't be a full solution as long as you need to interface with legacy code.

Don't get me wrong, I'm a sucker for C++ and RAII, but it's not the only-and-best solution for all scenarios.

Reply Parent Score: 2

sakeniwefu Member since:

How do you suspect it performs in heavily threaded code? (you need mutexing both on the refcount and on your heap).

Faster than GC if it was to free memory at the same rate.

GC performs better than manual memory management only in a small subset of scenarios. It is true that it is good enough for many more, and that it keeps dumb programmers from freeing used objects and the like.

However, as soon as their design assumptions aren't met they fail badly. Generational GC aces object creation and destruction benchmarks. As true as it is that it bloats up until virtual memory dries up, when faced with real world apps that don't follow the general rule.

Reply Parent Score: 2