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

Paulo Pinto pjmlp at progtools.org
Thu Jan 9 01:10:06 PST 2014


On Thursday, 9 January 2014 at 08:40:30 UTC, Ola Fosheim Grøstad 
wrote:
> On Thursday, 9 January 2014 at 07:07:29 UTC, Walter Bright 
> wrote:
>> and it works without copying in D, it just returns s1. In C, I 
>> gotta copy, ALWAYS.
>
> Only if you write libraries, in an application you can set your 
> own policies (invariants).
>
>> (C's strings being 0 terminated also forces much extra 
>> copying, but that's another topic.)
>
> Not if you have your own allocator and split chopped strings 
> (you can just overwrite the boundary character).
>
>> The point is, no matter how slow the GC is relative to malloc, 
>> not allocating is faster than allocating, and a GC can greatly 
>> reduce the amount of alloc/copy going on.
>
> But since malloc/free is tedious c-programmers tend to avoid it 
> by embedding objects in large structs and put a variable sized 
> object at the end of it... Or have their own pool (possibly on 
> the stack at the location where it should be released).

I have only seen those things work in small AAA class teams.


More information about the Digitalmars-d mailing list