Live data from Hacker News

Benchmark: C++ vs C#

codeproject.com

11–20 of 36 posts

Re: Benchmark: C++ vs C#

#11
post #9

I have heard that you can expect a 10-15% difference in most cases. However, it seems that there are just some arenas that C# wont quite measure up. I'm thinking multimedia applications would not scale well. Mainly because there is no way via Microsoft's .NET implementation to access SSE or other processor intrinsics. I know that mono announced that this a year or two ago, anyone have experience with it?

You're thinking of Mono.Simd. I've toyed with it a bit, and it seemed pretty fast, but I haven't yet had the chance to write something "real-world" with it.

Miguel de Icaza wrote an article with some preliminary benchmarks when they announced the release a few years back: http://tirania.org/blog/archive/2008/Nov-03.html

Re: Benchmark: C++ vs C#

#12
post #10
post #8

The results seem conclusive: if you're developing software for the desktop, and (like me) you are equally skilled in C# and C++, it's safe to take advantage of the simpler syntax, rich standard libraries, stellar IntelliSense and reduced development effort that C# offers. With the glaring exception of numeric code, which is the most crucial thing for a lot of apps that are now written in C++. You'd be crazy to write…

For these the best approach is to write the whole app in some higher-than-C++ level language with performance critical parts (usually less than 10 percent) in C/C++.

That's often a good approach, but sometimes the overhead of marshaling data between the layers can kill you. For instance, Google warns people about assuming the apps written using the Android NDK will be faster, partly because of JNI overhead.

Re: Benchmark: C++ vs C#

#13

I think he hit the nail on the head referring to c# programmers in general not being as "performance conscious" which leads the misconception that c# is a much slower language to use. I've worked in many places and have come across the same thing. As a c++ programmer I have also worked with c# coders and am often shocked at their slap-dash approach to software engineering. I'm not saying they're all like that but it…

Do you think those programmers would suddenly become "performance conscious" if they switched to c++? What I'm saying is that I don't see the point in referring to them as "c# coders" they could be using any language just as badly.

Re: Benchmark: C++ vs C#

#14

I think he hit the nail on the head referring to c# programmers in general not being as "performance conscious" which leads the misconception that c# is a much slower language to use. I've worked in many places and have come across the same thing. As a c++ programmer I have also worked with c# coders and am often shocked at their slap-dash approach to software engineering. I'm not saying they're all like that but it…

Maybe that's true, but I'm working on a Windows Phone 7 app right now that struggling to hit its performance targets. The major culprit? Silverlight's data-binding. Microsoft shipped the framework without shipping high performance controls necessary to meet the certification requirements of their app store (ListBox, I'm looking at you), so while our code might return the results of the list in <20ms, it takes another 800-1500ms for the results to be rendered. It's frustrating.

Re: Benchmark: C++ vs C#

#15
I don't know much C#, but it seems to me there are so many ways of writing "numeric" code in C++. Using the STL algorithms is one, using C-style looks on POD arrays another, and using an expression template math library like blitz yet another. You can't really say that any one of them, except possibly the expression template method, is uniquely C++.

Re: Benchmark: C++ vs C#

#16

I think he hit the nail on the head referring to c# programmers in general not being as "performance conscious" which leads the misconception that c# is a much slower language to use. I've worked in many places and have come across the same thing. As a c++ programmer I have also worked with c# coders and am often shocked at their slap-dash approach to software engineering. I'm not saying they're all like that but it…

I think one of the big reasons is that most C# developers are ASP.NET CRUD developers, where, most the time the bottlenecks are in HTTP i/o and in waiting for the database results. Optimizing C# for these applications is a waste of time.

You will find that a greater proportion of C#/Winforms, console apps, windows services etc. developers are performance conscious.

Re: Benchmark: C++ vs C#

#17
post #13

I think he hit the nail on the head referring to c# programmers in general not being as "performance conscious" which leads the misconception that c# is a much slower language to use. I've worked in many places and have come across the same thing. As a c++ programmer I have also worked with c# coders and am often shocked at their slap-dash approach to software engineering. I'm not saying they're all like that but it…

Do you think those programmers would suddenly become "performance conscious" if they switched to c++? What I'm saying is that I don't see the point in referring to them as "c# coders" they could be using any language just as badly.

Yeah I'd not label it a language issue but rather as you've already described it, as an implementation issue.

Re: Benchmark: C++ vs C#

#18

I think he hit the nail on the head referring to c# programmers in general not being as "performance conscious" which leads the misconception that c# is a much slower language to use. I've worked in many places and have come across the same thing. As a c++ programmer I have also worked with c# coders and am often shocked at their slap-dash approach to software engineering. I'm not saying they're all like that but it…

2 things:

1): Most projects that I've used c# for just aren't performance constrained. What's more important for us is the productivity dimension. We have _lots_ of hardware. We have a few programmers.

I've actually just finished the _only_ c# program that had a performance aspect. It was/is an in-house search engine. I profiled it, fixed the hotspots and it's fast enough.

2: MSFT Marketing. Linq|dynamic are heavily sold by Microsoft. You'll have to read Joe Duffy's blog for actual performance advice: http://www.bluebytesoftware.com/blog/2010/09/06/ThePremature...

Re: Benchmark: C++ vs C#

#19
I think C# is in the category of "fast enough".

When I was working through project Euler (http://projecteuler.net/) with various languages, the only one I really had to optimize was Python (vs C/C#/Haskell).

I really like Python, and for most stuff it's fast enough. Just saying the real penalty (that I noticed) is a scripting language, _if_ it's heavily arithmetically constrained.

Some (non-trivial) games in C#: http://www.arcengames.com/w/index.php/aiwar-alienbundle

http://murudai.com/solar/

However, it's possible and even practical to also write games in Python. See the pygame project.

Re: Benchmark: C++ vs C#

#20
post #8

The results seem conclusive: if you're developing software for the desktop, and (like me) you are equally skilled in C# and C++, it's safe to take advantage of the simpler syntax, rich standard libraries, stellar IntelliSense and reduced development effort that C# offers. With the glaring exception of numeric code, which is the most crucial thing for a lot of apps that are now written in C++. You'd be crazy to write…

http://www.getpaint.net/

I'm not saying paint.net is a replacement for photoshop. However, for me, it's in the "good enough" category.

http://en.wikipedia.org/wiki/Paint.NET

"Paint.NET is primarily programmed in the C# programming language, with small amounts of C++ used for installation and shell-integration related functions."

Again this is good enough for a lot of peoples image manipulation. That area of "good enough" is getting larger all the time.

Post reply on HN