Adding Java and C++ to the MQTT benchmarks or: How I Learned to Stop Worrying and Love the Garbage Collector

Benjamin Thaut code at benjamin-thaut.de
Wed Jan 8 12:23:48 PST 2014


Am 08.01.2014 20:15, schrieb H. S. Teoh:
> Manual memory management is a LOT of effort, and to be quite honest,
> unless you're writing an AAA 3D game engine, you don't *need* that last
> 5% performance improvement that manual memory management *might* gives
> you. That is, if you get it right. Which most C/C++ coders don't.
>

The problem is, that with the current D-GC its not 5%. Its 300%.  See: 
http://3d.benjamin-thaut.de/?p=20
And people who are currently using C++ use C++ for a reason. And usually 
this reason is performance. As long as D remains with its current GC 
people will refuse to switch, given the 300% speed impact.
Additionaly programming with a GC often leads to a lot more allocations, 
and programmers beeing unaware of all those allocations and the 
possibility that those allocations slow down the program and might even 
trash the cache. Programmers who properly learned manual memory 
management are often more aware of whats happening in the background and 
how to optmize algorithms for memory usage, which can lead to 
astonishing performance improvements on modern hardware.

Also a GC is for automatic memory management. But memory is just a 
resource. And there are a lot other resources then just memory. Having a 
GC does not free you from doing other manual memory management, which 
still can be annoying and can create the exact same issues as with 
manual memory management. Having a large C# codebase where almost 
everything implementes the IDisposeable interface doesn't really improve 
the situation. It would be a lot better if GCs would focus on automatic 
resource management in general, so the user is freed of all such tedious 
tasks, and not just a portion of it.

Additionaly switching away from C++ is also not a option because of 
other reasons. For example cross plattform compatibility. I don't know 
any language other then C/C++ which would actually work on all 
plattforms we (my team at work) currently develop for. Not even D 
(mostly because of missing ports of druntime / phobos. Maybe even a 
missing hardware architecture.)

But I fully agree, that if you do some non performance critical business 
logic or application logic its a lot more productive to use a garbage 
collected language. Unfortunately C# and Java are doing a far better job 
then D here, mostly because of better tooling and more mature libraries.

Kind Regards
Benjamin Thaut




More information about the Digitalmars-d mailing list