Announcement

Collapse
No announcement yet.

GCC Compiler Migrating To Be More C++ Based

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

  • GCC Compiler Migrating To Be More C++ Based

    Phoronix: GCC Compiler Migrating To Be More C++ Based

    Last week at Google's offices in London there was a gathering of GCC (GNU Compiler Collection) developers to discuss various topics from C++0x and GDB to the compiler's plug-in API. There are notes from this 2011 GCC Gathering on the GCC Wiki for those interested, but perhaps most interesting was their discussion surrounding the planned migration to C++. GCC itself is largely written in C at this point, but there's an effort under-way to switch more of this compiler code to being more C++ based...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    Just a subtle correction after reading the document, is that it's likely the churn will come about from differences of opinion of devs, not from c++ inclusion itself.

    Comment


    • #3
      As long as it doesn't affect the quality of the generated code, I don't care. Slow down and bloat the compiler; as far as my use cases go, it doesn't affect me. My CPU can chew through your templates and virtual function tables. Hopefully they buy you some degree of programmer-friendliness for gcc hackers.

      Compile time is not really an important stat for most people compiling stuff. Correctness and compatibility -- so that your code "just works" as intended -- and performance of the generated binaries is what matters the most.

      Comment


      • #4
        C++ is best described as making an octopus out of a dog by nailing extra legs to it.

        Bad move IMHO.

        Comment


        • #5
          Originally posted by allquixotic View Post
          As long as it doesn't affect the quality of the generated code, I don't care. Slow down and bloat the compiler; as far as my use cases go, it doesn't affect me. My CPU can chew through your templates and virtual function tables.
          Your CPU doesn't need to chew through that. Those things aren't computationally intensive. There's nothing to chew through.

          Comment


          • #6
            Anyone who thinks C++ makes code slower than writing the exact same code with the exact same behavior in more obtuse C code is an idiot, doesn't understand compilers, languages, CPUs/assembler, basic runtime architecture, operating systems, or pretty much anything about programming other than what they can read from other clueless, uninformed dipshits on the Interwebz. A template is no more bloated than a pile of macros that do the same thing. A virtual function call is no slower than using a function pointer table. An overloaded addition operator is no slower than calling an add_foo function. Etc. You could argue that exceptions cause overhead... if we were still in the 1990's and modern ABIs didn't have zero-overhead exception implementations, which GCC uses by default.

            Just sayin'.

            Comment


            • #7
              Originally posted by RealNC View Post
              Your CPU doesn't need to chew through that. Those things aren't computationally intensive. There's nothing to chew through.
              I think virtual functions add an extra layer of pointer indirection - and I'm sure you can design poorly written C++ that slows things down.

              However, in general, there's absolutely no reason a C++ app should be any slower than one written in C. There are even a few optimizations that apply only to C++ and aren't possible in C.

              Comment


              • #8
                Originally posted by smitty3268 View Post
                I think virtual functions add an extra layer of pointer indirection
                The impact is so small that using the term "chewing through it" is like saying that you need a chainsaw to cut a toothpick in half

                and I'm sure you can design poorly written C++ that slows things down.
                That's true for any language, of course.

                However, in general, there's absolutely no reason a C++ app should be any slower than one written in C. There are even a few optimizations that apply only to C++ and aren't possible in C.
                Yep. And the vtable can sometimes be bypassed entirely by the compiler, even when using pointers. But in general, even if not, the impact is a non-issue. When C++ first appeared, people were running systems with 66MHz i486 CPUs, and it wasn't an issue even then. So trying to make this an issue on systems that are orders of magnitude faster than this is simply dumb C++ has been used so much for GUIs and such, that people tend to forget that C++ is actually a high performance, systems programming language.

                Comment


                • #9
                  Originally posted by Obscene_CNN View Post
                  C++ is best described as making an octopus out of a dog by nailing extra legs to it.

                  Bad move IMHO.
                  That's still better than C, which is like a dog with no legs at all.

                  Comment


                  • #10
                    Originally posted by smitty3268 View Post
                    I think virtual functions add an extra layer of pointer indirection
                    Of course they do. Also obviously, if you actually _need_ virtual functions to implement a design, it turns out not having them is of significantly worse performance.

                    Look at the OOP patterns in Linux articles on LWN. The nice big fast Linux kernel is basically filled with vtables, except they're all written by hand in C. There's just as much indirection going on there as there is in any C++ vtable. Except the C compiler doesn't know when or how to automatically de-vritualize functions...

                    And sure, sometimes you don't need the extra level of indirection, and just storing a function pointer in the object instance is sufficient. Thankfully, unlike C#, Java, and almost every other "better than C++" OOP language out there, C++ is able to do all the things C can do just as fast as C can do them, so you can still just stick a function pointer in your objects in C++. And then wrap it in an inlined one-liner method so the call syntax stays just as clear (and just as IntelliSense-friendly).

                    Idiot C++ programmers will -- like any other idiot programmer -- misuse a language, often because they don't understand the language, don't understand programming in general (most computer science majors fall into that category, sadly), or just don't understand the program they're trying to write. A competent C++ programmer knows how to design and architect a large framework, knows when to use and not to use polymorphism, virtual functions, abstraction, etc. and when to do things bare to the metal (or even when to offload the work into an external tool/language).

                    Comment

                    Working...
                    X