Announcement

Collapse
No announcement yet.

GCC Moves Forward With Conversion To C++

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

  • Originally posted by LightBit View Post
    I didn't just bash C++, my complain is that this changes to internal interpreter of GCC will require C++ front-end (not to mention C++ library, if they use it) to compile, even if you only want C front-end. Trolling was not my intention.
    ok i try to explain it very simplified so you can grasp the concept, when you compile C your CPU dont have a C PU that understands C or a C++ PU[as processing unit] that understand C++ and gcc intend to use the C++ silicon to pass C code, this is impossible and this kind of cpu doesn't exist[would be retarded slow]

    what is a compiler? a compiler[very simplified] is an converter from Language X to IR[as intermediate representation][very very low level] to binary[<--simplified] which is the unique language your CPU can talk
    what are a compiler stages? well your code is most likely to be really inefficient from a CPU perspective[and well you code can be very crappy too] so the compiler has many optimization passes to fix this situation and improve the quality of the resulting binary code
    what is a language? since writing a software in binary is absoletely impossible for a human being in a regular lifetime, it was common sense to create a much more simplified way of communicate the CPU the task we need it to compute in a logical ordeal and after we end expressing our computing needs then use an automated translation tool to make it binary language[compiler] again so the cpu can get to work.
    What is C? is just a language which unique syntax and features that were used commonly enough to be able of make that syntax and features an ISO standard
    what is C++? is a syntax and features superset of C able to reach ISO standard as well that introduce a new set of tool to improve our way to write code that were developed after C was an ISO standard
    what is X language? same crap
    since C dont have OOP that means it don't use some parts of my cpu? no, it doesnt matter the language they all pass by a compiler in some point and get translated to binary using as many features as your CPU can handle[flags control this but keeping it simple]
    what make OOP different from C? is no magic at all is just syntax that allows to express logic in a more natural real world way[we use objects[apple], properties[color, texture, smell], etc in our daily life] where C is more a serialized syntax[do this, next do that, then do this 4 times and then do that thing there and then close][again very simplified]

    so the C interpreter inside the compiler is simple a parser that reads your X language code and translate it into an IR[gimple in GCC case] that much later will be writed in binary to a file[.o file (.exe or .so are made by a linker not a compiler) ] so the features or syntax of the language you use to write the parser are 100% irrelevant as long as you can properly translate to IR with it[so yes you can make a c interpreter in python or java if you want no biggie here], so using a bit more higher level to write this parser can allow you to write a smarter parser or at least a more readable parser than with a lower level language hence opening the possibility of apply further optimizations to the code that is getting parsed that would be too hackish or hard in a lower level language that is all

    Comment


    • Originally posted by jrch2k8 View Post
      ok i try to explain it very simplified so you can grasp the concept, when you compile C your CPU dont have a C PU that understands C or a C++ PU[as processing unit] that understand C++ and gcc intend to use the C++ silicon to pass C code, this is impossible and this kind of cpu doesn't exist[would be retarded slow]

      what is a compiler? a compiler[very simplified] is an converter from Language X to IR[as intermediate representation][very very low level] to binary[<--simplified] which is the unique language your CPU can talk
      what are a compiler stages? well your code is most likely to be really inefficient from a CPU perspective[and well you code can be very crappy too] so the compiler has many optimization passes to fix this situation and improve the quality of the resulting binary code
      what is a language? since writing a software in binary is absoletely impossible for a human being in a regular lifetime, it was common sense to create a much more simplified way of communicate the CPU the task we need it to compute in a logical ordeal and after we end expressing our computing needs then use an automated translation tool to make it binary language[compiler] again so the cpu can get to work.
      What is C? is just a language which unique syntax and features that were used commonly enough to be able of make that syntax and features an ISO standard
      what is C++? is a syntax and features superset of C able to reach ISO standard as well that introduce a new set of tool to improve our way to write code that were developed after C was an ISO standard
      what is X language? same crap
      since C dont have OOP that means it don't use some parts of my cpu? no, it doesnt matter the language they all pass by a compiler in some point and get translated to binary using as many features as your CPU can handle[flags control this but keeping it simple]
      what make OOP different from C? is no magic at all is just syntax that allows to express logic in a more natural real world way[we use objects[apple], properties[color, texture, smell], etc in our daily life] where C is more a serialized syntax[do this, next do that, then do this 4 times and then do that thing there and then close][again very simplified]

      so the C interpreter inside the compiler is simple a parser that reads your X language code and translate it into an IR[gimple in GCC case] that much later will be writed in binary to a file[.o file (.exe or .so are made by a linker not a compiler) ] so the features or syntax of the language you use to write the parser are 100% irrelevant as long as you can properly translate to IR with it[so yes you can make a c interpreter in python or java if you want no biggie here], so using a bit more higher level to write this parser can allow you to write a smarter parser or at least a more readable parser than with a lower level language hence opening the possibility of apply further optimizations to the code that is getting parsed that would be too hackish or hard in a lower level language that is all
      Yes, I understand. I don't say C compiler should be in C, because CPU would understand C, and of course quality of binary doesn't depend on language in which compiler was written.
      I don't like OOP, maybe because of bad experiences with C# and I really like C's serialized syntax, because it's very simple and straightforward, but I wasn't complaining about OOP anyway.

      You probably misunderstood my complain.
      I will try to explain with an example:
      You have a system with C compiler and libraries (and no C++ compiler or libraries), and than you want to upgrade C compiler with new one (version) which is written in C++, so you have to get C++ compiler and libraries first and that may be a bloat, if you don't need C++ compiler and libraries otherwise.
      You may say, you can get binary, but I want robust and portable compiler that can build itself and run with least dependencies possible.

      I just prefer C for essential stuff like C compiler.

      Comment


      • Originally posted by LightBit View Post
        Because users may need to compile that application.
        You have to really stretch your imagination to come up with a setup where a C++ compiler is not available. And if you're talking about the increase in compilation time that should not be a problem as gcc now supportes precompiled headers and also I suppose they will use C++11 features like extern templates that bring the compile time of C++ programs a lot closer to an equivalent C one.

        Comment


        • Originally posted by LightBit View Post
          Yes, I understand. I don't say C compiler should be in C, because CPU would understand C, and of course quality of binary doesn't depend on language in which compiler was written.
          I don't like OOP, maybe because of bad experiences with C# and I really like C's serialized syntax, because it's very simple and straightforward, but I wasn't complaining about OOP anyway.
          [...]
          You have a system with C compiler and libraries (and no C++ compiler or libraries), and than you want to upgrade C compiler with new one (version) which is written in C++, so you have to get C++ compiler and libraries first and that may be a bloat, if you don't need C++ compiler and libraries otherwise.
          You may say, you can get binary, but I want robust and portable compiler that can build itself and run with least dependencies possible.

          I just prefer C for essential stuff like C compiler.
          So:
          may be a bloat
          So your argument is firstly emotional: C++ (OOP in general) tends to have more bloated software because the C++ philosophy is to make everything bombastic. GCC is a bloated piece of software. I don't want to say I can write it better, but a compiler is a huge piece of software (7 millions of line of code as Phoronix states).
          Also, more featured software is bloated by itself, so why matter it works a bit slower (supposedly this will be the final result), when the compiling step is happening just once, and it does not happen on your phone, but on your multi-core machine?
          I want robust and portable compiler that can build itself and run with least dependencies possible.
          GCC in itself has dependencies that go well beyond the C library. In general compilers tend to use parser generators (like Bison).
          Let's take the next GCC version release notes:
          To enable the Graphite framework for loop optimizations you now need CLooG version 0.17.0 and ISL version 0.10. Both can be obtained from the GCC infrastructure directory. The installation manual contains more information about requirements to build GCC.
          Source: http://gcc.gnu.org/gcc-4.8/changes.html

          Want more?
          GCC now ships with the LGPL-licensed libquadmath library, which provides quad-precision mathematical functions for targets with a __float128 datatype. __float128 is available for targets on 32-bit x86, x86-64 and Itanium architectures. The libquadmath library is automatically built on such targets when building the Fortran compiler.
          Source: http://gcc.gnu.org/gcc-4.6/changes.html

          Let's say you will have two theoretical GCCs: one that compiles fast, and gives bad code (because it takes more to implement interesting optimizations), and one that compiles slow, but gets better code, because the codebase is flexible, what would you pick? Let's assume you will also know that C++ version of the future GCC is written in an ugly style.
          As for me the choice is obvious.
          At the end, about pro OOP/non OOP code: C++ OOP code is ugly and full of pitfalls (I worked professionally for years with C++), Java and C# are a bit better (as languages) but somewhat slower to run, and a bit too annoying. Being said that, a lot of code written in C# and in Java move huge application codebases (Eclipse platform comes first to mind). Release with release most big software is written in C++ (or Java or C#) and includes fairly big changes (Office 2007, had a UI rewrite, even wasn't the most popular) just because of flexibility of the C++ code.
          C on the other hand is mostly abstraction free, performance oriented. (I don't want to argue that C++ doesn't write fast code, at least because is 95% compatible with C). Which is to pick? I think is GCC developers choice. As more you will write C code that GCC can use it, they will use it. But as hacking into GCC gets slower and slower, maybe C++ was the natural choice for them.

          Comment


          • Originally posted by LightBit View Post
            Yes, I understand. I don't say C compiler should be in C, because CPU would understand C, and of course quality of binary doesn't depend on language in which compiler was written.
            I don't like OOP, maybe because of bad experiences with C# and I really like C's serialized syntax, because it's very simple and straightforward, but I wasn't complaining about OOP anyway.

            You probably misunderstood my complain.
            I will try to explain with an example:
            You have a system with C compiler and libraries (and no C++ compiler or libraries), and than you want to upgrade C compiler with new one (version) which is written in C++, so you have to get C++ compiler and libraries first and that may be a bloat, if you don't need C++ compiler and libraries otherwise.
            You may say, you can get binary, but I want robust and portable compiler that can build itself and run with least dependencies possible.

            I just prefer C for essential stuff like C compiler.
            well this could be a point but in that case gcc may not be the right tool for the job since the language interpreter is a very small part of the codebase so i think for extreme space constrained system PCC could be a smarter choice depending of your code ofc and you don't actually need c++ runtime per se to take space since you arent linking into c++ code at all so is very possible to use a very small subset of the runtime libraries coded internally just enough to get the parser work, i think is possible too just to treat C++ syntax as an internal HLIR[high level IR] without external dependencies only implementing what is minimaly neccesary for the interpreter and i don't think is neccesary to build g++ either as again you are not compiling or linking, is true tho gcc is quite massive and force C to build the C++ compiler/runtime won't affect too much the final installed size of the compiler[and taking the fact glibc is quite another mammut] i doubt it matter much.

            the best would be to wait until some patches land so we can determine the real impact of the method they choose cuz unlike many ppl believe to write a compiler is kinda requirement to be freaking uber smart and i doubt this type of person will do this task without have good reasons or at least without a clever idea about the implementation and i seriously doubt this land before gcc 4.9 or 5.0

            Comment


            • Originally posted by LightBit View Post
              You have a system with C compiler and libraries (and no C++ compiler or libraries), and than you want to upgrade C compiler with new one (version) which is written in C++, so you have to get C++ compiler and libraries first and that may be a bloat, if you don't need C++ compiler and libraries otherwise.
              You may say, you can get binary, but I want robust and portable compiler that can build itself and run with least dependencies possible.

              I just prefer C for essential stuff like C compiler.
              In cases like this one cross-compiling from a more general-purpose computer is probably a better bet anyway (the only reason you wouldn't have C++ stuff is that the computer had very limited space, in which case compiling on it is probably a bad idea anyway)

              Comment

              Working...
              X