Announcement

Collapse
No announcement yet.

GCC Moves Forward With Conversion To C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by mirv View Post
    Why would it take longer?
    You've not compiled both C and C++ lately, have you?

    Comment


    • #32
      Originally posted by curaga View Post
      You've not compiled both C and C++ lately, have you?
      you haven't made statements that make sense lately, have you?
      (sorry, couldn't resist that one)

      Seriously though, got anything to back up that statement, or do you believe it just because? If it's just because, you should probably go reading through the idea a bit more.

      Comment


      • #33
        Originally posted by curaga View Post
        You've not compiled both C and C++ lately, have you?
        So as far as I can tell, you are saying one of the two things:

        1. Compiling the exact same code for takes longer if you are compiling for C++.
        2. One or more of the specific changes they plan to make will result in a 20x slowdown in the build

        If it is 1, please explain why. If 2, please tell us which of those changes will have the effect and why. Otherwise I am curious how you justify this position. Just saying "C code compiles faster than C++ code" doesn't really mean much if you are comparing different code.

        Comment


        • #34
          If you use the STL, the compiles will be quite longer. Also, compiling the same classes in header files again and again just takes much longer then function prototypes.

          Comment


          • #35
            Originally posted by deanjo View Post
            *rolls eyes*

            [sarcasm]
            Ya because a language determines the quality of the code.
            [/sarcasm]
            Tell me about it; working on a major ADA program right now. You can write horrid code in any programming language.

            Comment


            • #36
              Originally posted by mirv View Post
              you haven't made statements that make sense lately, have you?
              (sorry, couldn't resist that one)

              Seriously though, got anything to back up that statement, or do you believe it just because? If it's just because, you should probably go reading through the idea a bit more.
              It's common knowledge. Even compiling plain C with g++ is slower than with gcc, by 35% here (n=6, hello world). If you actually use any C++ features, the gap grows.

              time gcc -o hello hello.c
              56ms

              time g++ -o hello hello.c
              76ms

              Comment


              • #37
                Originally posted by TheBlackCat View Post
                So as far as I can tell, you are saying one of the two things:

                1. Compiling the exact same code for takes longer if you are compiling for C++.
                2. One or more of the specific changes they plan to make will result in a 20x slowdown in the build

                If it is 1, please explain why. If 2, please tell us which of those changes will have the effect and why. Otherwise I am curious how you justify this position. Just saying "C code compiles faster than C++ code" doesn't really mean much if you are comparing different code.
                Both. See my post above about compiling C as C++. Then make a hello world in C++, using C++ idioms, features, and STL and time that.

                20x is simply a ballpark figure. But it's a fact that C++ is slow to compile, especially if templates are involved, as mentioned by RealNC.

                Comment


                • #38
                  Originally posted by curaga View Post
                  It's common knowledge. Even compiling plain C with g++ is slower than with gcc, by 35% here (n=6, hello world). If you actually use any C++ features, the gap grows.

                  time gcc -o hello hello.c
                  56ms

                  time g++ -o hello hello.c
                  76ms
                  Which is like using glxgears for opengl benchmarking. But just for shits and giggles, I ran that here and got....wildly different results for every run through, sometimes with gcc faster, sometimes with g++ faster. Also, -ftime-report is probably a bit better...

                  Now if you want to talk about how it's easier to abuse C++, which results in increased compile time, that's entirely different. Let's look at the flip side too: for comparable structures, if not using STL, then something else has to be written, which may be written poorly. Actually, you could theoretically save compile time in some areas due to OOP principles (who knows? that's why gcc-in-c++ is being looked at). You could also make it worse - none of which is a reflection on the language, but rather on the how it's being used.
                  Now let's also look at C++ vs C in terms of pure semantics which must be observed...in which case, sure, C++ has a bit more in the lexical analysis which must be handled (for example), but such overhead is going to be nowhere near what you're claiming - it's mostly likely going to be completely unnoticed.

                  Comment


                  • #39
                    Originally posted by mirv View Post
                    Which is like using glxgears for opengl benchmarking.
                    Here's building ncurses 5.9 with C and C++. For C++:

                    Code:
                    ./configure CC="g++" CFLAGS="-fpermissive -Wno-write-strings" CXXFLAGS="-fpermissive -Wno-write-strings" --without-cxx-binding
                    make -j4 # to warm disk caches
                    make clean
                    time make -j1
                    
                    real    0m47.392s
                    user    0m41.033s
                    sys     0m4.815s
                    For C:

                    Code:
                    make distclean
                    ./configure CFLAGS="-Wno-write-strings" CXXFLAGS="-fpermissive -Wno-write-strings" --without-cxx-binding
                    make -j4 # to warm disk caches
                    make clean
                    time make -j1
                    
                    real    0m42.323s
                    user    0m36.326s
                    sys     0m4.294s
                    All was done in a tmpfs so it's in RAM. And caches were warm by doing the build twice.

                    Comment


                    • #40
                      Originally posted by curaga View Post
                      It's common knowledge. Even compiling plain C with g++ is slower than with gcc, by 35% here (n=6, hello world). If you actually use any C++ features, the gap grows.

                      time gcc -o hello hello.c
                      56ms

                      time g++ -o hello hello.c
                      76ms
                      Question: How are you measuring time? Because I hope you're doing it in such a way where you choice of scheduler isn't affecting the results in some way...

                      Comment

                      Working...
                      X