Speed of different languages

This is a discussion on Speed of different languages within the Tech Board forums, part of the Community Boards category; Hey, Is there anywhere I can go to get an objective overview over how fast different languages are compared to ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485

    Speed of different languages

    Hey,

    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

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    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.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,160
    Quote Originally Posted by h3ro View Post
    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.
    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.

    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.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    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.

  5. #5
    Registered User
    Join Date
    Dec 2008
    Location
    Black River
    Posts
    128
    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.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    Quote Originally Posted by brewbuck View Post
    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.
    It will be my signature as soon as I finish posting this.

    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.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by Mario F.
    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%?
    Hmm, might want to read this before using that as an example. London Stock Exchange to abandon failed Windows platform.
    bit∙hub [bit-huhb] n. A source and destination for information.

  8. #8
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by brewbuck View Post
    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.
    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...

  9. #9
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,160
    Quote Originally Posted by EVOEx View Post
    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...
    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.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    Quote Originally Posted by bithub View Post
    Hmm, might want to read this before using that as an example. London Stock Exchange to abandon failed Windows platform.
    Interesting bit of information. Didn't know about it. Thanks. I'll certainly keep an eye on news about it.

    A few random thoughts though:

    • The author of the article is obviously quite biased. His language and his conclusions betray him.
    • It's not clear what exactly happened and why the system is being abandoned. But serving such a huge platform on machines running Windows 2003 and SQL server 2000 can be part of the answer. Not so much the capacity of managed code to answer the requirements.
    • The most meaningful arguments the author makes aren't provided along with a quote to validate them. It becomes his word. So I'm left without knowing exactly how did LSE underperfomed and by what margin, how faster exactly was Masketprizm.
    • He talks too much of his sources inside LSE but I never heard of this journalist before. he sould make a name for himself before expecting people to blindly accept his unnamed sources as evidence.
    • I couldn't find any sources where LSE admits they will be removing the platform. This article speaks of a Financial Times article. But couldn't find it anywhere.
    • Meanwhile I've read at least twice LSE is reported (1, 2) to have clearly stated this to not have been an issue with TradeElect (the managed software in question). Any comments of the type "oh, really?" are then left unquoted.

    Finally, I prefer this type of journalism.

    In any case thanks for that. You are right. At this point that becomes a bad argument.
    Last edited by Mario F.; 10-16-2009 at 06:06 PM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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.

  11. #11
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,534
    Quote Originally Posted by bithub View Post
    Hmm, might want to read this before using that as an example. London Stock Exchange to abandon failed Windows platform.
    Yeah, well... they deserve it for using .NET.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  12. #12
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    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.
    Unless you are requiring all of your customers to buy the new 25% faster computer. Let's say you have 5000 machines you need to replace to run your new code. Now the cost is not worth it.

    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.
    Last edited by VirtualAce; 10-17-2009 at 12:12 PM.

  13. #13
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Mario F. View Post
    Finally, I prefer this type of journalism.
    You mean the kind that involves a few phone calls to make sure the right parties will be reading what they want to see? No one at at FT is into MS stock (sarcasm), I'm sure, and this is not a boat many people will want to see rock.

    I guess we all believe what we like.
    Last edited by MK27; 10-18-2009 at 06:30 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I am very new . . . :(
    By Eternalglory47 in forum C++ Programming
    Replies: 6
    Last Post: 09-05-2008, 11:29 AM
  2. Flight Simulator Wind Speed!!
    By Dilmerv in forum C++ Programming
    Replies: 6
    Last Post: 03-19-2006, 11:40 PM
  3. Replies: 6
    Last Post: 01-08-2006, 01:49 PM
  4. increased net speed
    By PING in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-29-2005, 06:05 AM
  5. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 01:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21