Speed of C++

This is a discussion on Speed of C++ within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Originally Posted by vart And he does not want to wait 3-4 hours till the report will be build (he ...

  1. #46
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    Quote Originally Posted by vart
    And he does not want to wait 3-4 hours till the report will be build (he is not intrested to know what number of Megabytes to be parsed to generate report, he just wants to get the report in minutes, not hours)...
    So what are you saying?
    That on one programming language you can cut that down to minutes while on another it takes hours? Because that's what this is all about. Not performance issues spawned from bad programming, but speed comparison between programming languages.

    so no, I don't have any application to support, where the time issue is not critical... Bad luck?
    No. You are just missing the point of this debate.
    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.

  2. #47
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    I'm really not going into the debate of which is faster, C++ or Java.
    Your words, not mine.
    No. You are just missing the point of this debate.
    I'm not into debate. Have nothing to say about the issue. And don't want to.

    You said that for most application the time issue is not critical.
    I said - I have no application to support where the time issue is not critical. That's all. I make no futher suggestions, just stated the fact.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #48
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    > That's all. I make no futher suggestions, just stated the fact.

    Fair enough.

    I'm glad to know I'm right when I account for exceptions.
    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.

  4. #49
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    A fact that nicely points out the real issue: speed is far more about code design than the language used. If an application that generates a report from some data reads all data in, begins swapping like mad, to generate a report, then the most l33t assembly won't make it even remotely as fast as a program that reads the data incrementally (assuming the report allows that), even if that other program is written in JavaScript or Ruby (the current Ruby implementation is one of the slowest languages in wide use out there).
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #50
    Registered User
    Join Date
    Dec 2006
    Location
    Washington
    Posts
    18
    Quote Originally Posted by Laserve
    Oh my its decided! java is slower!



    What do *you* think you're actually testing here? this is nothing more than a I/O system test of 1 java and c++ implementation.

    And then, this just shows that you are a mediocre java programmer:

    For instance, have you any idea what this line is doing?

    System.out.println( i + " is an even number! " );

    You're using way more objects and dynamic memory allocations than is necessary. Those not needed 1000 objects may trigger a garbage collection sweep which will of course make you app slower.
    Try rewriting it with StringBuffer and Stringbuffer.append and give the results again
    Get Stuffed! Don't try to act like I don't know what is happening "behind the scenes" simply because I used it in the manner shown in my "test." I started programming in Java with JDK v.71 on Solaris before it was supported on any other platforms. Did you happen to notice that I also wrote it without any output? C++ is still way faster. Some would argue due to the JVM startup time. I don't care why, C++ and Java side by side, C++ will always be faster.

    Having discussed, at length, the thinking and activities that went into the creation of the Java programming language with James Gosling, I can say for sure that it wasn't ever meant to be a "better C++" as was offered by CornedBee. In fact, Gosling told me that the "best aspects of many" languages were borrowed from for the creation of Java, which was in response to my observerations of how Objective C-like it was in terms of GC, "import" vs include, "mother-of-all-objects" and single inheritance/interfaces.

    So, the bottom line is Java is for those who can't program in C++!

    As for being a mediocre Java programmer, at least I know that Java is capitalized!

    ...but, since you're the expert Java programmer and I'm simply mediocre, maybe you'll realize that there isn't even a need for a StringBuffer and the append call?!

    Code:
    final class even_numbers
    {
        public static void main( String[] args )
        {
            for( int i = 0; i < 1000; i++ )
            {
                if( i % 2 == 0 )
                {
                    //System.out.println( i + " is an even number! " );
                    System.out.print( i );
                    System.out.println( " is an even number! " );
                }
            }
        }
    };
    
    real    0m0.185s
    user    0m0.135s
    sys     0m0.034s
    
    C++
    real    0m0.017s
    user    0m0.002s
    sys     0m0.002s
    
    Java using StringBuffer (not printing the contents of the SB)
    real    0m0.138s
    user    0m0.082s
    sys     0m0.018s
    
    Java using StringBuffer (printing the contents of the SB)
    real    0m0.189s
    user    0m0.134s
    sys     0m0.024s
    Java is a DOG WITH FLEAS...if you need speed, you need C!

    And, since you're the world's gift to Java, maybe you'd be happy to learn that the JDK documentation recommends using StringBuilder over StringBuffer in single threaded applications. I'll quote the JDK documentation:

    "Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations."


    :davis:

  6. #51
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Why do you keep posting stats about 1000 iterations of nothing? Do you honestly think that measures something meaningfull? You said yourself that your example was trivial, yet you still quote your results. The fact that the example is pointless nullifies any result you obtain.

  7. #52
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    > In fact, Gosling told me

    He didn't tell you enough.

    > Java is a DOG WITH FLEAS...if you need speed, you need C!

    If you need speed you need a better computer. Meanwhile you haven't been listening...
    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.

  8. #53
    Registered User
    Join Date
    Dec 2006
    Location
    Washington
    Posts
    18
    Quote Originally Posted by Perspective
    Why do you keep posting stats about 1000 iterations of nothing? Do you honestly think that measures something meaningfull? You said yourself that your example was trivial, yet you still quote your results. The fact that the example is pointless nullifies any result you obtain.
    Hopefully you've obtained 2nd grade and realize that meaningful doesn't have two "L"s, but obviously, that is a waste of everyone's time here...

    The example shows that for the same code in C++ versus Java, that C++ is faster. Show me the same code in Java that is faster than in C++ or STFU.


    :davis:

  9. #54
    Registered User
    Join Date
    Jan 2007
    Posts
    8
    It's a bad comparison, C++ has had 5+ more years of optimazation and the compiler optimazation changes from year to year are starting to slow down; Java on the other hand is actively getting faster in its implementations. So I think the choice of which to use should depend on other factors (I personaly don't use Java because I use FreeBSD and it used to always be a .......... to install the JVM, so I am kinda biased). So instead of focusing on the current speeds, look instead at the projected speeds, in the near future (due to it becoming open source) I think Java implementations are going to become near the speed of C++.

  10. #55
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    Quote Originally Posted by :davis:
    Hopefully you've obtained 2nd grade and realize that meaningful doesn't have two "L"s, but obviously, that is a waste of everyone's time here...
    Because (and I think this is the second time I've said this to you), this isn't a place where we critique every detail of everyones English. I'm almost certain that the main subject of this board is programming, unless you know about a hidden section that focuses on being extremely anal about the English language.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  11. #56
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    > Hopefully you've obtained 2nd grade and realized that meaningful doesn't have two "L"s, but obviously, that is a waste of everyone's time here...

    same goes to you.

    > The example shows that for the same code in C++ versus Java, that C++ is faster. Show me the same code in Java that is faster than in C++ or STFU.

    Why? Do you think you made a point with your pathetic little example?
    "Look C++ is faster than Java because of these 10 lines of code". Do you even realize how ridiculous your whole argument is?
    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.

  12. #57
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Write something significant and come back to us, perhaps if it were to... do something?

    Or better yet, get an open mind, other languages exist and prosper for a reason, even if you don't like it. You can always just never let Java code execute on your computer and feel your leetness with all the speed.

    EDIT: Wow :davis: you got some balls, telling professionals to 'STFU' 'cause C++ executes a bit faster (which would become trivial in scaled examples.)
    Last edited by Wraithan; 01-10-2007 at 08:10 PM.

  13. #58
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,893
    C++ is still way faster. Some would argue due to the JVM startup time. I don't care why, C++ and Java side by side, C++ will always be faster.
    Well, you have used a specific example in an attempt to prove a universal statement, so your statement remains unproven. Even if you did manage to prove it, as pointed out by others in this thread, your conclusion only matters in some cases.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #59
    Insane Game Developer Nodtveidt's Avatar
    Join Date
    Nov 2006
    Location
    Isabela, PR
    Posts
    105
    I wasn't aware one could obtain 2nd grade...where do you put it once you've obtained it?



    Anyways, I think the only place Java is going to excel consistently is on Java-based cellphones...
    Code:
    cout << "Language comparisons are dumb";
    echo("Language comparisons are dumb");
    PRINT "Language comparisons are dumb"
    alert ("Language comparisons are dumb")

  15. #60
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    Next time try and write your godly code at the first attempt then
    The timings already went from 0.313 to 0.138 which is 3 times as fast on such a stupid example

    Quote Originally Posted by :davis:

    Old example from first page
    real 0m0.313s
    user 0m0.138s
    sys 0m0.030s

    Java using StringBuffer (not printing the contents of the SB)
    real 0m0.138s
    user 0m0.082s
    sys 0m0.018s
    I cant believe you keep defending this stupid example when you're the lord of the java code

Page 4 of 5 FirstFirst 12345 LastLast
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. Questions on Speed of Execution
    By wavering in forum C Programming
    Replies: 22
    Last Post: 01-20-2002, 01:04 PM

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