Jump to page: 1 26  
Page
Thread overview
D vs C++ - Where are the benchmarks?
Jun 30, 2013
Gabi
Jun 30, 2013
Joakim
Jun 30, 2013
Joakim
Jun 30, 2013
Gabi
Jun 30, 2013
monarch_dodra
Jul 01, 2013
Kapps
Jul 01, 2013
dennis luehring
Jul 01, 2013
Iain Buclaw
Jul 01, 2013
dennis luehring
Jul 01, 2013
Iain Buclaw
Jul 01, 2013
Iain Buclaw
Jul 01, 2013
Gabi
Jul 01, 2013
Iain Buclaw
Jun 30, 2013
SomeDude
Jun 30, 2013
Adam D. Ruppe
Jun 30, 2013
SomeDude
Jun 30, 2013
David
Jun 30, 2013
Jonathan M Davis
Jul 01, 2013
Jacob Carlborg
Jul 01, 2013
monarch_dodra
Jul 01, 2013
David
Jul 01, 2013
John Colvin
Jun 30, 2013
Gabi
Jun 30, 2013
Peter Alexander
Jul 01, 2013
Mehrdad
Jul 01, 2013
Jonathan M Davis
Jul 01, 2013
Marco Leise
Jul 01, 2013
Jonathan M Davis
Jul 01, 2013
Paulo Pinto
Jul 01, 2013
Joakim
Jul 01, 2013
monarch_dodra
Jul 01, 2013
Jonathan M Davis
Jul 01, 2013
Brad Anderson
Jul 03, 2013
Mehrdad
Jul 03, 2013
deadalnix
Jul 04, 2013
Mehrdad
Jul 04, 2013
Mehrdad
Jul 04, 2013
Jonathan M Davis
Jul 04, 2013
Mehrdad
Jul 04, 2013
Jonathan M Davis
Jul 04, 2013
Mehrdad
Jul 04, 2013
Mehrdad
Jul 04, 2013
Jonathan M Davis
Jul 04, 2013
Mehrdad
Jul 04, 2013
Jonathan M Davis
Jul 04, 2013
Paulo Pinto
Jul 04, 2013
H. S. Teoh
Jul 04, 2013
Mehrdad
Jul 04, 2013
H. S. Teoh
Jul 05, 2013
Paulo Pinto
Jul 05, 2013
Mehrdad
Jul 05, 2013
Iain Buclaw
Jul 05, 2013
Iain Buclaw
Jul 01, 2013
bearophile
Jul 01, 2013
Suliman
June 30, 2013
Hi D community,

I am new to D and got impressed with the language so much that I was thinking on introducing D it my workplace as an alternative to C++ which is heavily used on our projects.

The first question that came up was how it stands up with C++ performance wise ?

I didn't find D on the shootout site (why?) and didn't find almost any benchmarks comparisons.

Are there any good comparisons out there ?

Gabi
June 30, 2013
On Sunday, 30 June 2013 at 19:48:45 UTC, Gabi wrote:
> Hi D community,
>
> I am new to D and got impressed with the language so much that I was thinking on introducing D it my workplace as an alternative to C++ which is heavily used on our projects.
>
> The first question that came up was how it stands up with C++ performance wise ?
It's comparable.

> I didn't find D on the shootout site (why?) and didn't find almost any benchmarks comparisons.
It used to be in there and used to dominate the shootout.  D and Free Pascal used to be neck and neck for the top spot, if you weighted speed, memory, and code size the same.  But the guy who runs those benchmarks apparently didn't want to spend time on the D examples anymore, from what I can tell from this cryptic comment:

http://www.digitalmars.com/d/archives/digitalmars/D/The_Computer_Languages_Shootout_Game_120840.html

That site and D's dominance was one of the reasons I came to D early on.  It would be nice if he would take D back, but I haven't looked at that site in many years, so I'm not sure if it even matters anymore.

> Are there any good comparisons out there ?
Not that I know of, but then I'm not looking to justify the use of D anymore. ;)
June 30, 2013
On Sunday, 30 June 2013 at 20:05:16 UTC, Joakim wrote:
> On Sunday, 30 June 2013 at 19:48:45 UTC, Gabi wrote:
>> Are there any good comparisons out there ?
> Not that I know of, but then I'm not looking to justify the use of D anymore. ;)
When I just googled for "d programming language benchmark," this post was two clicks from the first page of search results:

http://attractivechaos.wordpress.com/2011/06/22/my-programming-language-benchmark-analyses/
June 30, 2013
On Sunday, 30 June 2013 at 19:48:45 UTC, Gabi wrote:
> Hi D community,
>
> I am new to D and got impressed with the language so much that I was thinking on introducing D it my workplace as an alternative to C++ which is heavily used on our projects.
>
> The first question that came up was how it stands up with C++ performance wise ?
>
> I didn't find D on the shootout site (why?) and didn't find almost any benchmarks comparisons.
>
> Are there any good comparisons out there ?
>
> Gabi

D used to be in the shootout, and was doing very good, right on par with g++. That was before Isaac Gouy, the maintainer of the shootout/benchmark game, decided to remove a number of languages, among which D. Don't ask us what his criteria are, noone knows for sure.

Overall, the performance of D can be extremely good. It is most often largely superior to Java, and it can even be better than C++ in non trivial programs, if one cares about not allocating too much on the heap. It seems indeed that the automatic memory management is a major performance killer, and it's not always easy to know in advance what the overall performance of D code will be. But the less work for the GC, the better.

To illustrate this, in one recent thread, one guy did a direct translation of his C++ raytracer to D. His first attempt wasn't very good, as the D version was almost 10x slower than the C++ version (with the same gcc backend), which is abnormal. A few simple optimizations later (without changing the algorithm), the D version was 40% faster than the g++ -O2 version. Another example of high performance is the std.regex library, which is known to be faster than all other implementations that we've heard of, in any language. So yes, one can get stellar performance out of D, but I would say right out of the box, it's not automatic, it does require some work where high performance is needed. However, out of all the existing languages, it's probably second only to C++.

Up until fairly recently, memory allocation was not considered a primary concern, so that some parts of the Phobos standard library do allocate memory behind the scene. But today, a lot of attention is being paid not to allocate when it's not absolutely necessary, and the standard library is slowly being expurged of unnecessary allocations. This is largely a manual process, though. In a not too distant future (say before 2014), some tooling will help detecting spurious memory allocations, so that there is good hope that the Phobos library will be essentially clean in that regard. Also, there is some work going on for a concurrent GC.
June 30, 2013
On Sunday, 30 June 2013 at 20:37:16 UTC, SomeDude wrote:
> It seems indeed that the automatic memory management is a major performance killer

Eh, I'd say it is D's gc implementation specifically that is the biggest worry rather than the concept. I think the .net gc is seriously like 10x faster than D's implementation.
June 30, 2013
On Sunday, 30 June 2013 at 19:48:45 UTC, Gabi wrote:
> The first question that came up was how it stands up with C++ performance wise ?

D, like C++, is a natively ahead-of-time compiled language. D also has very similar modelling, abstraction capabilities, and idioms to C++. The end result is that D programs are typically as fast as C++ programs, sometimes faster, sometimes slower.

It does depend on the compiler though. LDC and GDC will typically produce considerably faster code than DMD.

It's also worth mentioned that D's garbage collector isn't quite state-of-the-art, so programs that make heavy use of the GC may perform poorly. This will definitely improve, and there are already existing better GC implementations out there.
June 30, 2013
On Sunday, 30 June 2013 at 20:47:17 UTC, Adam D. Ruppe wrote:
> On Sunday, 30 June 2013 at 20:37:16 UTC, SomeDude wrote:
>> It seems indeed that the automatic memory management is a major performance killer
>
> Eh, I'd say it is D's gc implementation specifically that is the biggest worry rather than the concept. I think the .net gc is seriously like 10x faster than D's implementation.

Yes, yes, you're right. However, not allocating at least in Phobos is one of the surest way to get near optimal performance, not to mention it's always more satisfying when you know that your program doesn't monopolize Mb of RAM to do even the simplest task.
June 30, 2013
> C++ in non trivial programs, if one cares about not allocating too much on the heap. It seems indeed that the automatic memory management is a major performance killer, and it's not always easy to know in advance what the overall performance of D code will be. But the less work for the GC, the better.

I wonder why is that.. Why would deleting 1 million objects in C++ (using std::shared_ptr for example) have to be slower than the garbage collection freeing a big chunk of million objects all at once. I mean, it would probably block the main thread but the avg rate of deleting objects shouldn't differ from manually doing so right ? So the main issue would be unpredictable pauses (what's a typical delay to expect from cleaning 1000000 objects?) of the main thread and not avg performance I think..

> So yes, one can get stellar performance out of D, but I would say right out of the box, it's not automatic, it does require some work where high performance is needed.
Any other tips to get high performance besides the GC issue?
June 30, 2013
On Sunday, 30 June 2013 at 20:26:38 UTC, Joakim wrote:
> On Sunday, 30 June 2013 at 20:05:16 UTC, Joakim wrote:
>> On Sunday, 30 June 2013 at 19:48:45 UTC, Gabi wrote:
>>> Are there any good comparisons out there ?
>> Not that I know of, but then I'm not looking to justify the use of D anymore. ;)
> When I just googled for "d programming language benchmark," this post was two clicks from the first page of search results:
>
> http://attractivechaos.wordpress.com/2011/06/22/my-programming-language-benchmark-analyses/

Thanks for that. Unfortunately it doesn't contain dmd benchmarks which I most interested in because our main platform is windows.
June 30, 2013
On Sunday, 30 June 2013 at 21:06:37 UTC, Gabi wrote:
> On Sunday, 30 June 2013 at 20:26:38 UTC, Joakim wrote:
>> On Sunday, 30 June 2013 at 20:05:16 UTC, Joakim wrote:
>>> On Sunday, 30 June 2013 at 19:48:45 UTC, Gabi wrote:
>>>> Are there any good comparisons out there ?
>>> Not that I know of, but then I'm not looking to justify the use of D anymore. ;)
>> When I just googled for "d programming language benchmark," this post was two clicks from the first page of search results:
>>
>> http://attractivechaos.wordpress.com/2011/06/22/my-programming-language-benchmark-analyses/
>
> Thanks for that. Unfortunately it doesn't contain dmd benchmarks which I most interested in because our main platform is windows.

Let's just say "comparable": sometimes you'll get better, sometimes you'll get less. You have to keep in mind benchmarks are "synthetic", meaning they won't give you a good "real world view" of what you'll get in the end. Worst case scenario, D links with C and C++, so if you have some really nice "hand carved" C or C++ code, you can just link it in "as-is" (disclaimer, a bit complicated)

If you guys are already doing C++, then the shift should be relatively easy. The final experience with D (IMO) is that it is much simpler, much more enjoyable, and faster to develop. The drawbacks is that it is still buggy, not so stable (a bit of breakage every version, nothing major, but it's there). Another "problem" is that the "design patterns" for D are still being researched, and today's recommendation might be tomorrow's no-no...

I think the bottom line is that raw performance should not be your primary concern. As Marshall Cline states in his "big picture issues": "Choosing a language is a *business* decision". Evaluate the time/money you and your team will lose learning D, making the shift and maintaining code against a changing standard, then weight that against the time/money you'll gain using a higher level language like D. Once you've evaluated that, benchmark.
« First   ‹ Prev
1 2 3 4 5 6