![]() |
| | #1 |
| Registered User Join Date: Oct 2006 Location: UK/Norway
Posts: 464
| Speed of different languages Is there anywhere I can go to get an objective overview over how fast different languages are compared to each other? Im not looking for what langues are the fastest for certien operations, but more as a programming languages as a whole. I know that c/c++ is more or less the fastest you can get unless your willing to do crazy assembly stuff and is a guru when it comes to programming, my main goal is to see how big the difference is. The reason for why I am asking is that I have grown very found of c#, but I am often being told that it is a lot slower the c when it comes to pure data processing, and the program I am looking into starting on now is a ray tracer and I do not want to spend ages working on it only to later find that I could get a 25% speed increase or something by simply redoing it i c. And, I am not looking into starting a flame war, if admins feel that this is a bad road to go down, feel free to close this thread. Regards |
| h3ro is offline | |
| | #2 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| There's this: Square root of x divided by zero: The speed, size and dependability of programming languages Which I would reckon C# will probably be fine based on that. If I were you, I would come up with my own parallel tests in C & C#, something akin to the kind of data processing you want to do, and benchmark those.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is offline | |
| | #3 | |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Quote:
As always, optimize algorithms first. Then profile, and optimize hotspots. If necessary, thunk out to native code for extremely time-sensitive operations. But rewriting a well-written program in another language just to get some fixed performance boost is crazy.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot | |
| brewbuck is offline | |
| | #4 |
| Guest Join Date: Aug 2001
Posts: 4,923
| There's certainly no reason why a C# program must run slower, as it could be converted directly to machine code and thereby optimized further. In fact both Java and C# already have such facilities available (gcc, for instance, allows you to compile Java code directly). So it basically just boils down to how efficient the implementation is, really. In any case, whatever language you choose, there is generally a way to incorporate components written in assembly language if things get really tight. |
| Sebastiani is offline | |
| | #5 |
| Registered User Join Date: Dec 2008
Posts: 71
| Normally, I do a quick check at http://shootout.alioth.debian.org to have a general idea of how languages fare in terms of speed. The implementations of some of their programs could be a bit better though, but in general, I found them to be accurate. I agree with brewbuck in that a 25% gain is just not worth it. Perhaps if your application absolutely needs the performance boost you could make the switch, but then you'd also have to consider the development time and the extra dependencies (Since C's standard library will most likely be insufficient for such a task). Last edited by Ronix; 10-16-2009 at 07:21 PM. |
| Ronix is offline | |
| | #6 | |
| (?<!re)tired Join Date: May 2006 Location: Portugal
Posts: 5,220
| Quote:
As for the initial question. I'm currently studying the programming language. I'm not an expert on these matters by far, but you can still be a monkey and perform simple and yet intensive data processing tests. From what I observed so far there's absolutely no reason to believe C# under-performs in any way when compared to C or C++. If anything one could expect a slight delay initiating the application as its assembled CIL is compiled on the fly. But after that, when you hit the Run Tests button, I can't see much difference between any of the languages. So the only disadvantage in terms of performance I can imagine on an application written in C# is if it needs to be executed several times in quick succession and for some reason it is being compiled by the JIT everytime. Meanwhile NGEN eliminates the need for JIT compilation. As this technology matures (or so one can hope), it's expectable that those few areas where C# still has trouble matching C++ performance (3D programming rings a bell) will disappear. But as far as raw data processing is concerned, quite frankly only bad intentions can say the language is slower. The London Stock Exchange run on a managed platform written in C#. I can hardly think of higher requirements concerning performance and volume of raw data processing. Especially coming from one of the busiest stock exchange markets in the world. These things run in real-time, process huge volumes of data and even have to have an uptime of... 99.9%? Tell that to those people you hear saying C# is slow. And if they are developing an application that has higher performance requirements than the London Stock Exchange, then promise them you will pay attention to what they have to say. Otherwise you know where to send them.
__________________ Originally Posted by brewbuck: Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster. | |
| Mario F. is offline | |
| | #7 | |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| Quote:
__________________ bit∙hub [bit-huhb] n. A source and destination for information. | |
| bithub is offline | |
| | #8 |
| Registered User Join Date: Oct 2008
Posts: 452
| Say that to professional game developers or operating system programmers, where 25% performance boost may very well be a significant difference. And where asking all the users to get a PC that's 25% faster may kill your project... |
| EVOEx is offline | |
| | #9 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Professional game programmers and operating systems developers tend to think more carefully about their choice of language BEFORE starting a huge project, not a significant way into the project.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
| | #10 | |
| (?<!re)tired Join Date: May 2006 Location: Portugal
Posts: 5,220
| Quote:
A few random thoughts though:
In any case thanks for that. You are right. At this point that becomes a bad argument.
__________________ Originally Posted by brewbuck: Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster. Last edited by Mario F.; 10-16-2009 at 06:06 PM. | |
| Mario F. is offline | |
| | #11 | |
| Unregistered User Join Date: Jul 2007
Posts: 925
| Quote:
__________________ GCC 4.4.0, Code::Blocks 8.02, Fedora 11, x64 | |
| Yarin is offline | |
| | #12 | |
| Super Moderator Join Date: Aug 2001
Posts: 7,470
| Quote:
Also everyone forgets that if you want to distribute C# you should be bringing it down to native since anyone but anyone can get a small app off the net and read your source from the assembly. Once you bring it down to native you lose the speed and size benefits of C#. C# is a great language but let's keep it in it's rightful place. It was not designed to completely replace C/C++ and I doubt it ever will. But combined with C/C++ and C++/CLI it does offer some very nice flexibility and makes language interop much easier. After messing around with XNA and comparing it with the same type of app in C++ there really isn't a comparison. The native DirectX code ran almost 3 times as fast in debug as the XNA in release. The test was based on FPS measurements. I cannot reveal the details of the test but the C++ was doing far more and had several scripts running behind the scenes whereas the XNA did not. Even with all that C/C++ and native D3D were doing inefficiently it still trashed XNA's performance by a factor of 2 and sometimes 3. So basically brute-force D3D destroyed optimized XNA. The only thing that XNA did well was texture loading since it compiles all your resources into a binary format which appears to load very quickly. Overall not impressed with the XNA side. Basically it tells me if I optimize XNA as I would optimize Direct3D I will still be slower by a factor of 2 or 3 if I were to use it for what I need to do. Unacceptable.
__________________ If you aim at everything you will hit something but you won't know what it is. Last edited by Bubba; 10-17-2009 at 12:12 PM. | |
| Bubba is offline | |
| | #13 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
I guess we all believe what we like.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS Last edited by MK27; 10-18-2009 at 06:30 AM. | |
| MK27 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I am very new . . . :( | Eternalglory47 | C++ Programming | 6 | 09-05-2008 11:29 AM |
| Flight Simulator Wind Speed!! | Dilmerv | C++ Programming | 6 | 03-20-2006 12:40 AM |
| Calculating total distance travelled from time and varying speed | collin | C Programming | 6 | 01-08-2006 02:49 PM |
| increased net speed | PING | General Discussions | 20 | 03-29-2005 07:05 AM |
| Strange loop | D@rk_force | C++ Programming | 22 | 12-18-2004 02:40 PM |