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

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Thu Jan 9 10:18:32 PST 2014


On Thursday, 9 January 2014 at 17:15:46 UTC, Walter Bright wrote:
> How does that work when you pass it "hello"? allocated with 
> malloc()? basically any data that has mixed ancestry?

Why would you do that? You would have to overload cat then.

> Note that your code doesn't always have control over this - you 
> may have written a library intended to be used by others, or 
> you may be calling a library written by others.

The typical C (and the old C++) way has been to roll your own to 
get what you want and only use very focused libraries (like zlib, 
fft etc), or only use one big framework that define all their own 
stuff in a efficient and uniform manner with their own systems 
(Qt etc).

But it becomes tedious when using more than one framework.

> That doesn't work if you're passing strings with mixed ancestry.

Well, you have to decide if you want to roll your own, use a 
framework or use the old C way.

The point is more: you can make your own and make it 
C-compatible, and reasonably efficient.

Usually there are different representations that are more or less 
efficient or convenient based on what you want to do. Even for 
strings.  For instance, you can have a high speed ascii MSB  
string representation that is 64 bit aligned and that sorts fine 
using 64 bit uint, and which is 0 terminated (padded to the 8 
byte-aligned boundary).


More information about the Digitalmars-d mailing list