D vs Java

Sean Kelly sean at f4.ca
Mon Mar 20 10:02:42 PST 2006


Dave wrote:
> In article <dvld6m$1f37$1 at digitaldaemon.com>, Sean Kelly says...
>> similar semantics and C++ is far more heavily optimized.  If Java could 
>> make one performance claim over C++ it would be that manipulating 
>> references could be more efficient than passing copies, but D could make 
>> the same claim... and can also take advantage of the optimizations that 
>> contribute the performance of C++.
> 
> But C++ can also pass (and return) by reference if needed (obviating the need to
> call copy ctors), correct? And it can allocate class objects on the stack, which
> is an option Java doesn't have.

I think the important distinction is that you can do almost anything in 
C++ as the situation dictates.

Bjarne had a presentation on C++ performance where he presented hard 
data where C++ was shown to outperform highly tuned C code and even 
Fortran by multiple orders of magnitude.  This was achieved through the 
use of templates (implicit template instantiation is basically necessary 
for this), which were unique to C++ until D came along :-)  He also made 
a point of saying that when people compare performance between languages 
they typically compare specific language features, which I don't think 
presents a very accurate picture of things.  If someone has an example 
of Java outperforming C++, I suspect it's this kind of example, ie. 
comparing a tuned Java program to a badly written C++ equivalent using 
deep inheritance trees, DMA, and tons of virtual method calls with no 
optimization being performed.  In the hands of experts, I think Java has 
no chance of competing with C++, and I don't see that changing 
tremendously with time.  What Java has going for it is utility, not speed.


Sean



More information about the Digitalmars-d mailing list