GCC Moving To Use C++ Instead of C 546
An anonymous reader writes "CodeSourcery's Mark Mitchell wrote to the GCC mailing list yesterday reporting that 'the GCC Steering Committee and the FSF have approved the use of C++ in GCC itself. Of course, there's no reason for us to use C++ features just because we can. The goal is a better compiler for users, not a C++ code base for its own sake.' Still undecided is what subset of C++ to use, as many contributors are experts in C, but novices in C++; there is a call for a volunteer to develop the C++ coding standards."
Re:What... (Score:4, Informative)
Enjoy [google.co.uk]
Incorrect headline (Score:5, Informative)
Re:What... (Score:2, Informative)
No, they don't. That's how they did it back when the first compilers were made. Now everybody just uses an existing compiler, or in case there isn't one, cross-compiles on another system. And if you aren't a compiler developer, you simply download a precompiled binary of the compiler you want, or purchase an installation disc with the binary.
Re:The devs don't know C++?? Its a C++ compiler! (Score:5, Informative)
I think you're confused. Strictly speaking, GCC isn't even a C compiler.
GCC stands for "GNU Compiler Collection". In that collection, there's a C compiler as well as a C++ compiler, a Java compiler, and many more (they are not completely separate, they actually share a lot of code between them). All of them are written in C, and the news here is they're going to be written in C++ in the near future.
Re:From the article it is obvious (Score:5, Informative)
Because ObjectiveC is a slow shit?
Seriously, it might be OK for designing GUI interfaces, its dynamic nature helps there. But for compiler writing I'd prefer something:
1) Fast.
2) Typed.
3) Deterministic (no non-deterministic GC).
Re:From the article it is obvious (Score:1, Informative)
GCC already uses a garbage collector [gnu.org] internally although it has to be triggered explicitly.
The two main reasons for choosing a subset of C++98, instead of a different language, were mentioned on the mailing list. The most important reason is C++ will be the easiest to pick up by GCC hackers which are mostly accustomed to plain C.
The second reason mentioned were specific features of C++ like simple templates (STL containers) and multiple inheritance. They're taking everything slowly and at the moment there's no consensus even about the use vtables and RTTI.
Re:Finally! (Score:1, Informative)
You're not parsing correctly. He's talking about app/whatever code written using tons of #defines to work around bugs and features in different vendors compilers.
Re:C++? (Score:1, Informative)
Even Objective-C is better.
What do you mean "even"? I consider Obj-C to be a pretty great language.
Re:thus a disaster (Score:5, Informative)
You'll see exceptions, then memory leaks, an attempt to solve it with some kind of braindead "smart" pointer, somebody needs multiple inheritance, some ass overloads the comma operator or () operator, overloading gets sort of ambiguous with differences between the 32-bit and 64-bit builds, Boost gets pulled in with compile times and start-up times going to Hell, people cry for Java-style garbage collection...
If the first thing you get from C++, coming from C, is exceptions, then you're going to be in a world of pain. Most people who started with C++ have trouble with it. For a quick indication why, see Code Complexity @ GOTW.ca [www.gotw.ca].
As a 10-year veteran of C++, I say to start with RAII [wikipedia.org], and since you're going OO, require everyone involved to learn the SOLID principles [lostechies.com].
Re:Seems odd... (Score:5, Informative)
At best, the compiler would date back to Grace Hopper, as she was the person who invented the compiler. I believe it was for Fortran.
Re:Seems odd... (Score:5, Informative)
Re:From the article it is obvious (Score:1, Informative)
If anyone is interested about the speed of various different dispatch mechanisms, I've done some profiling [oriontransfer.co.nz]
Re:Maybe they've grown up a bit (Score:5, Informative)
Re:Seems odd... (Score:2, Informative)
Re:Out of the ashes and into C++ (Score:3, Informative)
Re:Seems odd... (Score:3, Informative)
Re:Maybe they've grown up a bit (Score:3, Informative)
Here, let me fix that for you:
Using c++ might free you from having to do manual memory management - just make sure you type a free for every malloc, and that your free gets called when the object goes out of scope (usually in the destructor). Then as the stack pointer gets unwound, the destructor calls your free.
Have an explicit contract with any other objects or code that uses data this object has allocated - which you should be doing anyway or your code will be thrown out by the next person who has to maintain it.
Re:C++? (Score:3, Informative)
Re:What... (Score:5, Informative)
Or even from the GCC build instructions [gnu.org]:
Re:Choices, choices (Score:3, Informative)
Actually you have it almost completely backwards.
A program like "Hello World" with be much, much faster in C than any of the Java derivatives like C#. A language that has a runtime requiring an expensive initial malloc for it's generational GC and a lot of fancy class/assembly loading will be an order of magnitude slower.
However a long running application is where the language's JIT features really shine, as they're able to optimize and reoptimize whereas a statically compiled language cannot. This is where you hear about "java faster than C++" simply because Java is dynamically compiled and C++ is statically compiled. C# has similar abilities.
Re:The devs don't know C++?? Its a C++ compiler! (Score:2, Informative)
The Ada front end is written in Ada.
Re:Choices, choices (Score:3, Informative)
Actually there is, it's called array bounds checks removal and escape analysis. ;)