Announcement

Collapse
No announcement yet.

C++ Doesn't Change The Speed Of GCC

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

  • C++ Doesn't Change The Speed Of GCC

    Phoronix: C++ Doesn't Change The Speed Of GCC

    With GCC 4.8 using C++ as its implementation language of the compiler, some have questioned whether the compiler is as fast as when written in C. Here's some benchmarks showing C vs. C++ performance with GCC...

    http://www.phoronix.com/vr.php?view=MTMzMzc

  • #2
    The switch to c++ wasn't about immediate speed benefits though. It was about cleaning up code and not reinventing the wheel with ideas and design because c++ had them and plain c didn't. So the fact they are even bringing this topic UP...is moot

    Comment


    • #3
      Originally posted by Ericg View Post
      The switch to c++ wasn't about immediate speed benefits though. It was about cleaning up code and not reinventing the wheel with ideas and design because c++ had them and plain c didn't. So the fact they are even bringing this topic UP...is moot
      A lot of people (read: idiots) thought that using C++ would make GCC slower, and hence that it should be avoided.

      It's like the people here who claim all that matters is the speed of compiled binaries, which as a (game) developer is one of the last things on my mind, but people perpetrate myths about what the purpose of a compiler is. A compiler is a tool, and the easier it is to use that tool, the better it is.

      Comment


      • #4
        C++ isn't inherently slower than C. Especially with C code compiled as c++ using a few token C++ features. The fun starts when C++ is used to overengineer a piece of software, not unlike most Java code I've seen. That's not the language's fault but a problem with the coder. C just doesn't scale quite as easily.

        Comment


        • #5
          Where exactly is the c++ implementation? I downloaded 4.8 and I still see only .c files, except ofcource libstdc++ and libjava.

          Comment


          • #6
            Originally posted by zoomblab View Post
            Where exactly is the c++ implementation? I downloaded 4.8 and I still see only .c files, except ofcource libstdc++ and libjava.
            "C++ implementation" may be misleading. What actually happens is that now GCC code base can be compiled using C++ compiler and new functionalities can be implemented using approved C++ features, as well as some code clean up. So there are still lots of C code, which won't be changing unless necessary.

            Comment


            • #7
              Originally posted by manphiz View Post
              "C++ implementation" may be misleading. What actually happens is that now GCC code base can be compiled using C++ compiler and new functionalities can be implemented using approved C++ features, as well as some code clean up. So there are still lots of C code, which won't be changing unless necessary.
              Which also renders the blog referenced in this news moot: Migrating to C++ for implementation is not about immediate improvement, but long term benefits.

              Comment


              • #8
                Originally posted by zoomblab View Post
                Where exactly is the c++ implementation? I downloaded 4.8 and I still see only .c files, except ofcource libstdc++ and libjava.
                gcc/hash_table.* for instance already uses C++. Not every abstraction that GCC uses (which essentially emulates C++ via C) will be converted to C++ native equivalents but a significant number of them might be.

                Comment


                • #9
                  Originally posted by elanthis View Post
                  A lot of people (read: idiots) thought that using C++ would make GCC slower, and hence that it should be avoided.
                  However, it will make compilation of GCC itself slower.

                  Comment


                  • #10
                    Originally posted by LightBit View Post
                    However, it will make compilation of GCC itself slower.
                    The article itself says not.

                    Comment


                    • #11
                      Originally posted by LightBit View Post
                      However, it will make compilation of GCC itself slower.
                      Not necessarily, especially when used responsibly. Remember that GCC has a lot of special pre-compilation code to run on itself for various "extensions" like gengtype. Removing those steps and replacing them can make things faster.

                      Also, C++ is generally not slower to compile unless using templates (including the STL of course) or exceptions. Exceptions are turned off here and templates are limited to sensible uses where they have a real benefit. With some templates compilation may be a little slower but if that greatly reduces code complexity then your development time is still under a net improvement. I'd be fine with a little longer build if it meant hours or even days shaved off of feature work. Build time is important because it impacts iteration time; language and tools are more important because they impact iteration time even more.

                      Comment


                      • #12
                        Originally posted by Luke_Wolf View Post
                        The article itself says not.
                        No, in article Linux kernel compilation was timed.

                        Comment


                        • #13
                          Originally posted by elanthis View Post
                          Not necessarily, especially when used responsibly. Remember that GCC has a lot of special pre-compilation code to run on itself for various "extensions" like gengtype. Removing those steps and replacing them can make things faster.

                          Also, C++ is generally not slower to compile unless using templates (including the STL of course) or exceptions. Exceptions are turned off here and templates are limited to sensible uses where they have a real benefit. With some templates compilation may be a little slower but if that greatly reduces code complexity then your development time is still under a net improvement. I'd be fine with a little longer build if it meant hours or even days shaved off of feature work. Build time is important because it impacts iteration time; language and tools are more important because they impact iteration time even more.
                          Yes it depends how much C++ functions they use. But does it make sense to use C++ without C++ functions?

                          Comment


                          • #14
                            Originally posted by LightBit View Post
                            Yes it depends how much C++ functions they use. But does it make sense to use C++ without C++ functions?
                            Without STL? Yes, definately. The big win with C++ is classes, templates, a better type-system and constructors/destructors for safer and cleaner state handling.

                            Comment


                            • #15
                              Originally posted by LightBit View Post
                              But does it make sense to use C++ without C++ functions?
                              What do you mean by "functions"? C++ is much (not all...) about classes, so why not use "classes"?
                              And that's one great plus:
                              classes with constructors and destructors. RAII. Not having to think about "which objects need to get destroyed in this error case"?
                              GCC currently uses macros/static inline functions and so on for "emulating" functionality they get for free in a much more pleasant way when using C++. (think of inheritance, generic structures like lists, ...)

                              Comment

                              Working...
                              X