D vs C++ - Where are the benchmarks?

Jonathan M Davis jmdavisProg at gmx.com
Thu Jul 4 14:45:46 PDT 2013


On Thursday, July 04, 2013 23:20:47 Mehrdad wrote:
> On Thursday, 4 July 2013 at 21:11:57 UTC, Jonathan M Davis wrote:
> > Well, of course portable C++ code won't assume that you have a
> > GC.
> 
> But portable D code will, so it really _is_ an advantage of the
> language, not just the compiler...

Sure. There's lots of stuff (like slices) which are an advantage of the 
language, because they're built-in and/or just easier to do. My point was that 
given enough time and effort, you can do anything in C++ that you can do in D. 
So, if you only want to consider things that _can't_ be done in C++ as 
relevant when comparing the speed of the languages (which seems to be what you 
were arguing for), then I don't believe that there is any difference in what 
you can do or how fast it will be. They are both turing complete languages and 
both give you the same level of access to the hardware. The entire difference 
lies in how easy they make it to write programs and what paradigms and idioms 
are easiest to write and use in them.

There's no point in even trying to compare the two languages for speed if 
you're trying to compare possible speeds (ignoring what paradigms and idioms 
they use) rather than comparing their relative speeds when using the normal 
idioms and paradigms that they use simply because they ultimately give you the 
same capabilities if you work hard enough at it.

> > My point was that it's perfectly possible to write C++ code
> > which uses a GC, not that it was normal or easy.
> 
> No, the point is that it would only with a particular C++
> compiler.
> It's not "C++" code if a C++ compiler can't run it correctly.
> That would make it "a vendor-specific language similar to C++"
> code.

Maybe I'm not well-enough informed, but I'm not aware of any reason that you 
can't implement a GC in C++. Maybe you can't do it with new without the 
compiler's help, and it may be a royal pain, but you have control over the 
memory layout and can put whatever extra information you want there in order 
to facilitate a GC.

- Jonathan M Davis


More information about the Digitalmars-d mailing list