Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

GCC Moving To Use C++ Instead of C

kdawson posted more than 4 years ago | from the keeping-with-the-times dept.

GNU is Not Unix 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."

cancel ×

546 comments

I think it's a sign of impending apocalypse (2, Insightful)

Anonymous Coward | more than 4 years ago | (#32415952)

Either that, or could we be about to see the beginning of a gcc/llvm compiler arms race?

As everyone forgot EGCS vs GCC back in Linux 2.x (0, Insightful)

Anonymous Coward | more than 4 years ago | (#32416164)

Damn I remember how everyone was fighting with different versions of slightly different compilers. Kernels of Linux back in 2.0 and 2.2 were a mess, and I was maintaining Caldera OpenLinux distributions numbered 2.1 to 2.3 (those aren't Linux kernel versions, but box product revisions). Yeah, I was the sole user that Darl McBride prided himself on just because OpenLinux was specialized for the better IPX network share support that my Fortune 10k company needed. Thankyou PJ and Groklaw sandwitchcraft for the smoke and mirrors.

Re:As everyone forgot EGCS vs GCC back in Linux 2. (1)

Pikoro (844299) | more than 4 years ago | (#32416416)

I have a Caldera OpenLinux T-shirt from back in the day. I still wear it around once a week (because it's the only linux tshirt I have)

Seems odd... (2, Interesting)

man_of_mr_e (217855) | more than 4 years ago | (#32415956)

I'm guessing that only the C++ compiler part will be written in C++. Sort of an Ouroborus.

One of the reasons for gcc being in C for so many years is that it was easier to get a bootstrap c compiler running on a given platform to compile the full gcc toolchain, but I would guess that a C++ compiler was not that important to those people anyways, but it still begs the question.. how do you get a C++ compiler working on a platform that doesn't have one?

Re:Seems odd... (1)

man_of_mr_e (217855) | more than 4 years ago | (#32415974)

After a few moments of thought, the answer seems obvious, so i'm ansing my own question. They will likely have a bootstrap C++ compiler written in C that is capable of compiling the full C++ compiler.

Re:Seems odd... (5, Insightful)

Capena (1713520) | more than 4 years ago | (#32415998)

how do you get a C++ compiler working on a platform that doesn't have one

Why not bootstrap using a cross compiler?

Re: ding ding winner (-1, Offtopic)

Anonymous Coward | more than 4 years ago | (#32416124)

Mod up. This is the correct answer to man_of_mr_e (217855)'s question.

Re:Seems odd... (5, Funny)

Anonymous Coward | more than 4 years ago | (#32416310)

now I'd like to see the graph of what was used to compile each compiler, until the first one written at hand on perforated cards, programmed for abacus in the classical ages

Re:Seems odd... (5, Funny)

FlyingBishop (1293238) | more than 4 years ago | (#32416624)

With the nodes that insert a backdoor into the unix login program colored red.

Re:Seems odd... (1)

Joce640k (829181) | more than 4 years ago | (#32416008)

ie. They could use any of the current compilers for the 'bootstrap'...

Re:Seems odd... (1)

man_of_mr_e (217855) | more than 4 years ago | (#32416028)

That would be wasteful, they could however strip down one of the current compilers and make it a "bare minimum" of features necessary to support the compiler.

Re:Seems odd... (2, Insightful)

Joce640k (829181) | more than 4 years ago | (#32416088)

Thinking even harder ... they could compile GCC on another machine but set the output target as the platform they're trying to get it to run on. Then you just copy the binary across.

Nope (1)

Weezul (52464) | more than 4 years ago | (#32416254)

They'll implement the new machine code generation routines in C++ just like now, and then cross compile gcc.

Re:Seems odd... (0)

Anonymous Coward | more than 4 years ago | (#32416016)

GCC has always claimed that they are going the "we can bootstrap ourselves" way.

Re:Seems odd... (1)

Sigurd_Fafnersbane (674740) | more than 4 years ago | (#32416022)

Since there are platforms for which C++ compilers exist you can compile the compiler on one of these and then cross-compile for the target platform.

This is also how you boot-strap a C-compiler on a platform it is not implemented for initially.

Re:Seems odd... (1)

man_of_mr_e (217855) | more than 4 years ago | (#32416044)

Yes, that is one way to do it, but my point was that gcc has always prided itself on being able to bootstrap itself with minimal work, and without cross compilation. Cross compilation was sort of considered to be "cheating"

Re:Seems odd... (1)

Sigurd_Fafnersbane (674740) | more than 4 years ago | (#32416114)

I get your point.

It might be possible to maintain a "gcc-light" compiler written fully in C and then have the gcc build scripts completing this boot-strap compiler first. The gcc-light do not need to be fast or effective since it will only be used for boot-strapping. It might even be possible to make it as a pre-processor converting c++ into C.

Re:Seems odd... (3, Interesting)

Philip_the_physicist (1536015) | more than 4 years ago | (#32416544)

If they used an early enough variant of C++, they would be relatively straightforward, since that has already been done once (cfront), but templates would probably make things somewhat harder, and would probably require a decent macro language. If they want some of teh nicer-sounding features of C++0a, things might start getting very horrible quite quickly.

Maybe they've grown up a bit (2, Interesting)

Joce640k (829181) | more than 4 years ago | (#32416402)

Maybe they've admitted that 'pride' is holding them back and that being able to use STL (for example) is a greater good than being able to do an initial compile on some obscure microcontroller which has a barely functioning C compiler.

Re:Seems odd... (0, Redundant)

Yvanhoe (564877) | more than 4 years ago | (#32416282)

The solution is called cross-compilation [wikipedia.org] .
You generate a binary for system Y on system X thanks to a compiler compiled in system X binary format.

Re:Seems odd... (0, Redundant)

Cyberax (705495) | more than 4 years ago | (#32416328)

Cross-compilation from a working platform.

It's not like many people don't have access to a platform powerful enough now. The need to bootstrap GCC from any platform only with K&R C has evaporated long ago.

Re:Seems odd... (1)

cyberthanasis12 (926691) | more than 4 years ago | (#32416514)

The real question is how do you compile the OS on the platform.

Re:Seems odd... (0)

Anonymous Coward | more than 4 years ago | (#32416578)

To be fair, it is right that the only real compiler (ie not a toy like Microsoft's) is built using a real language (ie not a toy like Microsoft's C#, or, heaven forbid, VB lol). C++ programmers are the best, most experience programmers around, and getting them on board the GCC project is undoubtedly a good idea.

Re:Seems odd... (1)

Jaydee23 (1741316) | more than 4 years ago | (#32416644)

If I remember correctly, things may have changed, C++ is supposed to be implemented as a precompiler for C. Which means that for a new system you need only need to transfer the precompiled output (C) and then put it through a bootstrap C compiler on the new system. As I say things may have changed.

Great (2, Funny)

jimmydevice (699057) | more than 4 years ago | (#32415960)

We have to pick through the preprocessor output to find the broken bits.

C++? (0, Flamebait)

Anonymous Coward | more than 4 years ago | (#32415964)

C++ is the most horrible language I've ever had to write code in. I think they should have sticked to pure C.

Re:C++? (1, Interesting)

Anonymous Coward | more than 4 years ago | (#32415996)

AC you got that right! C++ is macro for programmers that don't grok struct and pass by ref

Re:C++? (3, Insightful)

man_of_mr_e (217855) | more than 4 years ago | (#32416010)

It's not a horrible language if you take into account it's requirements. C++'s requirements are horrible and make it the monster it is. It has to have all the low-levelness of C with all the high level goodness of a modern OO language. Languages like Java, C#, Ruby, etc.. all have the advantage of not having to be a low-level language as well. While OS's have been written in languages like Pascal (original MacOS for instance and early versions of Windows) those were also largely custom compilers that added low-level functionality to the language.

So basically, C and C++ are unique in that they are required to be systems languages as well as applications languages. This makes both of them quirky to say the least.

Re:C++? (1)

Homburg (213427) | more than 4 years ago | (#32416138)

C++ is also required to be more-or-less compatible with C, and with various different pre-standard dialects of C++, which both prevents removing some of unpleasant parts, and means that new features have often had to be added in fairly baroque forms.

Re:C++? (1, Insightful)

Anonymous Coward | more than 4 years ago | (#32416148)

I would call the "high level" part a goodness. It's overly complex, making it too complex to understand, and hard to read and write code. C is already hard, but this is because of the low level part which you can't go without, and C++ just makes it insane.

And some language decisions are troubling. Abusing left and write shift with streams? I nearly puke when I see code like that. Couldn't they just have a 'write' and 'read' methods? It's confusing as to whether the code is doing shifts, or writes, or what, making it hard to read.
Template metaprogramming? Macros were already a way to make everything horrible, now there are even more things that allow you to do this. While it is a useful feature, any template code is nearly incomprehensible.
References for me are just more complicated pointers that only make code even harder to understand. And if you're doing high-level OO programming you should be avoiding using such constructs, just pass or return an object that carries the required information. Returning values through arguments like that is a bad idea, like all the things that references allow you to do. f(x) changing the value of x is a completely unexpected and surprising result for me. In C at least it had to be f(&x). Not to mention the use of & for references confuses the hell out of me.

Everything new, including the good things, like == overloading, and the way they are implementing, contributes to the extreme complication and insanity of C++.

C++ is the most horrible Object Oriented system you could add on top of C. Even Objective-C is better.

Re:C++? (4, Insightful)

jandersen (462034) | more than 4 years ago | (#32416186)

C++'s requirements are horrible and make it the monster it is

I don't think you are right there. I used to be very sceptical about C++, but I have had to develop some tools with it recently, and my respect for it has grown a good deal.

It is true that C++ programs can be real horrors to maintain and even to write, but I think the problem often lies with the design of the toolset used. That and the fact that C++ operates on a higher level of abstraction and therefore requires much more careful consideration and planning. The problems I have seen in the past have all been centered around people not quite understanding the nature of C++ and wanting to immediately put all those bright new features to "good" use, by overloading everything and indiscriminately inheriting from any number of classes.

The secret to good programming has always been to keep it simple - this is twice as important in C++, and the language has some great features for doing so, but you really have to understand what it is you are trying to achieve.

thus a disaster (5, Insightful)

r00t (33219) | more than 4 years ago | (#32416470)

That and the fact that C++ operates on a higher level of abstraction and therefore requires much more careful consideration and planning.

Planning... so you plan, then write, and you are done? This is a project that is expected to live for decades. The requirements change.

If you need more planning, that's a bad sign.

The problems I have seen in the past have all been centered around people not quite understanding the nature of C++ and wanting to immediately put all those bright new features to "good" use, by overloading everything and indiscriminately inheriting from any number of classes.

Yes. Expect it to happen, despite any efforts to resist. This is the nature of a project with more than one developer.

The secret to good programming has always been to keep it simple - this is twice as important in C++, and the language has some great features for doing so, but you really have to understand what it is you are trying to achieve.

Human brains are not SMP hardware. A group of people working together will not all see the same big picture.

Nobody on Earth fully understands all of C++. Every C++ programmer knows a subset. My subset is not your subset; it is unique to me as yours is to you. Features I love make you uneasy at best, and your pet features do likewise for me.

The features sneak in here and there... well I just can't resist because I really NEED my favorite feature! Think of the classic 2-circle Venn diagram for two people's C++ knowledge: you might hope for your project to be that intersection in the middle, but it's going to end up with the big fat union of pet features.

Really, you can't stop it. Resistance is futile.

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...

Re:C++? (2, Insightful)

Anonymous Coward | more than 4 years ago | (#32416058)

Oh, it's got its pros and cons, just like any language. At least with C++, you can point at any given piece of the language, and whether or not you like that piece, understand why it was designed that way. At least with C++, there are rational explanations for why it is the way it is. If C++ is the worst thing you've ever used then I strongly suggest trying to do something nontrivial in AppleScript; C++ will seem pretty awesome after that. :)

Transitioning from C to C++ (1)

Decollete (1637235) | more than 4 years ago | (#32415988)

Although I am not a contributor (for now at least, maybe), I want to follow how the developers will transition from C to C++. I mostly use C at work but I want to learn C++ as well. However, most of the time, I'd rather code in C than in C++ because I am that uncomfortable with it. Maybe the last time I used it is back in college, and that translates to not knowing much of it at all.

Linus will raise! (1, Interesting)

Anonymous Coward | more than 4 years ago | (#32416012)

considering he sustained that C++ is utter crap and that is why he didn't use it to develop git.... I just long for his rants... ^_^

What... (1)

f3rret (1776822) | more than 4 years ago | (#32416014)

How do you compile a compiler written in the language it compiles...

Re:What... (3, Informative)

Ckwop (707653) | more than 4 years ago | (#32416048)

How do you compile a compiler written in the language it compiles...

Enjoy [google.co.uk]

Re:What... (2, Insightful)

zebslash (1107957) | more than 4 years ago | (#32416056)

Well, ever thought that issue also happened for a gcc written in C? Compilers come with minimal bootstrap compilers written in assembler to initiate the first compilation. Then compilers compile themselves several times until they reach a final version.

Re:What... (2, Informative)

Anonymous Coward | more than 4 years ago | (#32416132)

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:What... (1)

BetterThanCaesar (625636) | more than 4 years ago | (#32416064)

First you compile it with another compiler. Then you have a binary with which you can compile the compiler.

Re:What... (1)

hey (83763) | more than 4 years ago | (#32416448)

The other compiler can be a previous version of the same compiler.

Re:What... (1)

BetterThanCaesar (625636) | more than 4 years ago | (#32416094)

Quis compilat ipsos compilatores?

Re:What... (5, Funny)

josgeluk (842109) | more than 4 years ago | (#32416358)

Quis compilabit ipsos compilatores?

ecco, tibi fixi .

Out of the ashes and into C++ (4, Funny)

trialcode (1400591) | more than 4 years ago | (#32416052)

Great idea! This will surely help steal back users from LLVM/clang. The reason people are jumping ship is because they want a compiler written in C++, it has nothing to do with performance, licenses and/or features. Just thinking about those crunchy templates, page up and page down, makes my mouth water. I can't even begin to comprehend how they ever got anything done without templates.

Re:Out of the ashes and into C++ (-1, Flamebait)

Anonymous Coward | more than 4 years ago | (#32416086)

boycott Israel !!!

Re:Out of the ashes and into C++ (0)

bonch (38532) | more than 4 years ago | (#32416140)

So sarcastic, it makes my teeth itch.

Re:Out of the ashes and into C++ (0)

Anonymous Coward | more than 4 years ago | (#32416194)

Great idea! This will surely help steal back users from LLVM/clang.

Disregarding the sarcasm in the rest of the post, LLVM's compiler is currently implemented by replacing GCC's backend with LLVM. This means C++ code gets into the compiler and whilst GCC is "Mainline = C only" it is impossible to declare GCC+LLVM an officially supported combination.

By most accounts I've read, LLVM generally produces superior code and is designed to function as a research and experimentation platform so it's an obvious choice to use that as the backend (perhaps keep the GCC specific one but de-emphasise it).

On the other hand, it may not have much to do with LLVM at all and instead just be intended to allow use of classes and stronger type checking for better internal organisation.

Re:Out of the ashes and into C++ (1)

nitehorse (58425) | more than 4 years ago | (#32416234)

You jumped right on the LLVM part, but apparently don't know what clang is. You should read about clang. http://clang.llvm.org/ [llvm.org]

Re:Out of the ashes and into C++ (1)

serviscope_minor (664417) | more than 4 years ago | (#32416370)

Great idea!

Indeed.

This will surely help steal back users from LLVM/clang.

I hope so.

So, you don't think that writing in a higher level language will lead to better performance and features? Perhaps you should start campaining to have LLVM rewritten in assembly language (or the LLVM intermediate language).

As for licenses, time will tell. Back in the Bad Old Days, every vendor and his dog had their own compiler. Because most vendors were not terribly good at writing compilers, writing portable code was really, really hard. Given how much more complex compilers have become, we really don't want to return to those days. GCC and the GPL have really helped in this regard.

Being the only fully featured, open source C++ compiler meant that the choice was low cost, low effort and openness, versus very high cost, high effort and closedness, the vendors chose GCC. Having basically a common. good, standards compliant compiler has made my life so much easier.

So yeah as someone who suffered for years under the heel of shoddy vendor compilers, I really hope that the compiler world does swing back to gcc. It'd be better for business all round.

Re:Out of the ashes and into C++ (1)

ZorbaTHut (126196) | more than 4 years ago | (#32416496)

As opposed to the closed inaccessible LLVM/Clang combo?

The GCC developers have shown their ability to compete with MSVC. For a while, they had the edge. They no longer do, and part of that, from what I know, is thanks to how grim and unmaintainable the GCC codebase is.

Personally, I'm quite excited for something better, and I'm really excited for something better that can be embedded in other projects.

From the article it is obvious (0)

FithisUX (855293) | more than 4 years ago | (#32416066)

that they are in need of ObjC without garbage collection. Why use C++ and artificially constrain its capabilities? There is also GnuStep project and ObjC has a clearer and simpler syntax than C++ with single object inheritance, and C99 extension (easy migration path). I cannot understand their reasoning for C++ if they are targeting a single subset and not the full standard. The only plus for C++ is the extensive use of IDEs. Otherwise it makes no sense.

Re:From the article it is obvious (1, Interesting)

Rockoon (1252108) | more than 4 years ago | (#32416146)

I 100% agree. A compiler would benefit very little by being moved to C++. Any "OO" use would be almost exactly single instance, and templates wouldnt be part of the subset they would allow. So what, the stream operators? sigh.

Re:From the article it is obvious (0)

Mad Merlin (837387) | more than 4 years ago | (#32416230)

They're allowing the STL but not custom templates. The STL alone makes C++ worth using.

Re:From the article it is obvious (1, Troll)

Rockoon (1252108) | more than 4 years ago | (#32416240)

So, a library? Really? Think about it.

Re:From the article it is obvious (4, Informative)

Cyberax (705495) | more than 4 years ago | (#32416372)

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 (1, Informative)

Anonymous Coward | more than 4 years ago | (#32416490)

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:From the article it is obvious (1)

Cyberax (705495) | more than 4 years ago | (#32416564)

I'm aware of garbage collector in GC. However, it's completely deterministic, and GCC people don't want to change it.

I tried to do some GCC hacking 3 years ago before I gave up and used LLVM.

Choices, choices (4, Insightful)

Cee (22717) | more than 4 years ago | (#32416068)

To paraphrase Einstein [wikiquote.org] :

Make things as simple as possible, but not simpler.

IMHO, one should use as high level language as possible, but not higher. One should never choose a lower level language than necessary only because it is hard core, the choice has to be based on something more substantial.

I've met several C programmers having the knee-jerk reaction when they hear the word C++ that it's bloated and slow and hard. And tell me what, they haven't read Stroustrup's FAQ [att.com] lately. C++ can be very lean and mean indeed. As can C# (which I'm mostly using right now).

Re:Choices, choices (0)

Anonymous Coward | more than 4 years ago | (#32416156)

High level != Simple. Ruby is quite high level, but you'd be amazed by the amount of crappy Ruby code out there..

Re:Choices, choices (4, Insightful)

daid303 (843777) | more than 4 years ago | (#32416236)

If you want to link to any FAQ, don't forget the FQA about C++ http://yosefk.com/c++fqa/ [yosefk.com]

Reading it will give you an inside on the many issues you can have with C++. I don't oppose C++, but You Have To Know What You Are Doing (TM). Or else all hell breaks lose. Fixing bad C is doable, fixing bad C++ is the 7th circle of hell.

Re:Choices, choices (5, Insightful)

serviscope_minor (664417) | more than 4 years ago | (#32416384)

The C++ FQA is mostly a bunch of rhetoric and sophistry with a good scattering of half-truths thrown in for good measure. It is a classic propaganda piece as the falsehoods are spread very continuously spread and mixed with truthful pieces. That makes it hard to debunk in a short post as one has to go in to nit-picking detail in order to expose it for the hokum that it really is. Fortunately, you can use your favourite search engine to search tha annals of comp.langg.c++.moderated for such information.

Re:Choices, choices (1)

LinuxAndLube (1526389) | more than 4 years ago | (#32416518)

I don't oppose C++, but You Have To Know What You Are Doing (TM).

Actually, that's why I like C so much: you don't have to know what you're doing!

Re:Choices, choices (0)

Anonymous Coward | more than 4 years ago | (#32416388)

It's not that it's bloated or slow. It's that it's retarded and misdesigned. It's as if C was reinvented with slightly different semantics for no real benefit.

So, if you present FAQ, I have to counter it with FQA [yosefk.com] .

Re:Choices, choices (0, Troll)

Joce640k (829181) | more than 4 years ago | (#32416494)

The C++ bashers are an undereducated bunch of whiners. Telling a C++ programmer to go back to C is like telling a C programmer to go back to assembly language, not going to happen. Deciding how to allocate CPU registers to get the tightest loop might be fun for a while but it simply doesn't work when you've got to write a real program.

Just like C compilers which allocate registers for you (and do a pretty good job!), a C++ compiler makes coding MUCH EASIER and MORE RELIABLE by doing all the micromanagement for you.

Anybody who thinks "C++ is C with a few extra things" is very, very wrong.

Re:Choices, choices (0)

Anonymous Coward | more than 4 years ago | (#32416592)

Have you read the announcement? No? Come on! it's not like it's an article, is it? OK, OK, this is Slashdot after all...
Well, the funny thing is that they have agreed to use C++, but they still have to discuss what to do with it!!
I will repeat it just in case: They don't have any idea of how (or if) it will be of any help.
Talk about irony...

Incorrect headline (5, Informative)

Letharion (1052990) | more than 4 years ago | (#32416098)

The headline says "Use C++ instead of C" which is incorrect. C++ is, as made obvious from the text, an option, not a requirement.

Re:Incorrect headline (1)

jimmydevice (699057) | more than 4 years ago | (#32416218)

When using C++, C is always there. C++ can be rightly ignored. Screw it's contextual syntax.

AVR-GCC (1)

dohzer (867770) | more than 4 years ago | (#32416102)

Will this feed through to things like AVR-GCC for Atmel AVR 8-bit microcontrollers?
I wonder what changes in performance we would see.

http://winavr.sourceforge.net/ [sourceforge.net]

Re:AVR-GCC (0)

Anonymous Coward | more than 4 years ago | (#32416122)

AVR-GCC can already compile C++, like all other GCC versions (AFAIK). The language in which the compiler itself is written won't affect users directly, unless it results in flaky behavior.

And frankly, it doesn't sound like a C++ guru convention is going on over there.

The devs don't know C++?? Its a C++ compiler! (5, Funny)

Viol8 (599362) | more than 4 years ago | (#32416116)

Are they seriously trying to suggest that the people who work on developing and maintaining a C++ compiler are novices in C++??

Sorry , am I missing something here?

Re:The devs don't know C++?? Its a C++ compiler! (-1)

Pinhedd (1661735) | more than 4 years ago | (#32416150)

GCC is not a C++ Compiler, it is a C compiler. There is an existing C++ compiler available but it is not part of the GCC and the GCC does not use C++. The debate is about allowing GCC to handle C++ as well as C.

Re:The devs don't know C++?? Its a C++ compiler! (0)

Anonymous Coward | more than 4 years ago | (#32416178)

Wrong. GCC has a C compiler, a C++ compiler, a Object-C compiler, a Java-Compiler, a Fortran compiler and a Ada Compiler.... and also libraries and extra tools useful for those languages.

Re:The devs don't know C++?? Its a C++ compiler! (5, Informative)

chocapix (1595613) | more than 4 years ago | (#32416224)

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:The devs don't know C++?? Its a C++ compiler! (1)

Homburg (213427) | more than 4 years ago | (#32416228)

GCC is both. The GNU C Compiler is a C compiler; the GNU Compiler Collection includes the GNU C Compiler, G++ (a C++ compiler), and maybe various other compilers (I can't remember whether GJC for Java, GNAT for ADA, or anything else, are part of GCC); these compilers share a lot of their functionality (abstract syntax trees, code generation), with the separate languages being multiple front-ends for a language-agnostic back-end. So it wouldn't be surprising if a number of the developers of this back-end didn't know C++.

Rubbish (1)

Viol8 (599362) | more than 4 years ago | (#32416260)

$ g++ -v
Reading specs from /usr/lib/gcc/i486-slackware-linux/4.3.3/specs
Target: i486-slackware-linux
Configured with: ../gcc-4.3.3/configure --prefix=/usr --libdir=/usr/lib --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,java,objc --enable-threads=posix --enable-checking=release --with-system-zlib --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --with-arch=i486 --target=i486-slackware-linux --build=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 4.3.3 (GCC)

That looks like gcc to me

Re:The devs don't know C++?? Its a C++ compiler! (0)

Anonymous Coward | more than 4 years ago | (#32416300)

What's the hell are you talking about ?!

GCC, the GNU Compiler Collection

The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, and Ada, as well as libraries for these languages (libstdc++, libgcj,...).

Re:The devs don't know C++?? Its a C++ compiler! (1)

bgarcia (33222) | more than 4 years ago | (#32416398)

Be kind.

Parent is obviously one of the GCC developers.

Re:The devs don't know C++?? Its a C++ compiler! (5, Funny)

dgriff (1263092) | more than 4 years ago | (#32416452)

Are they seriously trying to suggest that the people who work on developing and maintaining a C++ compiler are novices in C++??

Car analogy time! You can be an expert car mechanic without knowing how to drive.

I'll get me coat...

Re:The devs don't know C++?? Its a C++ compiler! (1)

Ed Avis (5917) | more than 4 years ago | (#32416520)

gcc (or any compiler) has several stages; as a minimum a front-end and a back-end. It's quite possible that people hacking on the back-end, generating optimized machine code for particular processors, know nothing of C++ or Ada or Fortran or the other languages for which gcc has a front-end.

Great ! Another printout to burn (2, Funny)

abies (607076) | more than 4 years ago | (#32416134)

Looking at the GNU Coding Standard [gnu.org] which is used for gcc, whatever 'best practices' and style guideline they come with will make a good fireplace material [kernel.org] ...

Finally! (2, Interesting)

serviscope_minor (664417) | more than 4 years ago | (#32416158)

For this kind of job, C++ really is better than C. One of C++'s goals was to standardise things people were doing in C anyway (eg OOP). The advantage of C++ is that the compiler writes all the boilerplate for you. Not only that, but it does it right every single time. Every line of code you don't write is one that does not have a bug.

The main problem is that it is easy to write a basic C compiler and thereby bootstrap a system. With GCC's cross-compiler abilities, this is less of a problem than it might otherwise be, since bootstrapping can always be done on an exitsing, supported platform.

The other solution is for the GCC developers to open up the middle end (like LLVM has done). This would allow one to relatively easily target the compiler to output C, and even a very simple subset thereof, making the bootstrapping process easy. I appreciate their reasons for not wanting to make this easy: they want to prevent proprietary front ends making a mockery of the GPL. I personally think that in this case, they have gone in the wrong direction, and opening up the middle end would yield far more open, copyleft compiler front ends.

Kind of like FUSE has done for filesystems. Sure, it is easier to write a proprietary filesystem than it has ever been for linux. But it is also vastly easier to write free ones too. The end result is that there are far more Free (tm) and interesting filesystems than there ever were.

So, I think in this case that by making lift harder for developers, they have done a bit more damage than would have been caused by accidently making life easier for proprietary developers.

But, that's my $0.02. And I'll keep supporting GCC, not LLVM because it is GPL. I don't want to see the return of the bad old days of code full of #defines written to work around missing features and bugs in 100 different, bad vendor compilers.

Re:Finally! (1)

Renegade88 (874837) | more than 4 years ago | (#32416322)

What do you mean, "return of bad old days"? Have you actually viewed GCC code? It's still full of #defines.

Conversely, I'll keep rooting for LLVM because it's not GPL licensed.

Re:Finally! (1)

serviscope_minor (664417) | more than 4 years ago | (#32416422)

Bad old days: did you ever try to write portable C or C++ code in the (say) mid 90's on UNIX? Or more recently on embedded platforms.

They all sucked. Now most of them use GCC, life has got a whole lot better.

That is what I mean by the bad old days.

And I'll keep rooting for GCC because it is under the GPL. It acieved what Stallman set out to do, make life one whole heckuva lot better for end users (i.e. me, the schmuck writing code) of the compiler in this case through the use of Free software. So yeah. I like GCC being under the GPL.

Re:Finally! (1, Informative)

Anonymous Coward | more than 4 years ago | (#32416512)

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:Finally! (0)

Anonymous Coward | more than 4 years ago | (#32416376)

I once used a C compiler on CPM which was a shell script. You could see it step through the preprocessor, code generator and assembler.

C++ flame wars (5, Funny)

o'reor (581921) | more than 4 years ago | (#32416242)

starting in 3... 2... 1...

Here's somme ammo from bash.org [69.61.106.93] :

Phil: C++ is java's uncle that never comes to visit, and had half his face blown off when he stepped on a landmine, also he's a pedophile.
Phil: But he's the industry standard.
David: and runs much faster
Phil: He has to be able to run fast, he's a pedophile.

Safe subset (5, Insightful)

steveha (103154) | more than 4 years ago | (#32416302)

The GCC guys are not going crazy here. They are discussing what subset of C++ to allow.

If you use all the wild features of C++, the results could be scary. For example, operator overloading is great if used judiciously, but if used badly it can make the code a mess. And if it is used at all, then it means that you can't look at one page from a printout and know for sure what that code does; you need to look at all the class functions to make sure there aren't tricky overloaded operators.

I use plain C all the time at work, and the top C++ feature they should be using is simply the object-oriented class stuff. With a single global namespace you need to make functions like MyClassAddFloatAndInt(), but in C++ you could just call that function add(); it would be part of MyClass, and if you have other "add" functions with other type signatures, they won't collide. They could go from:

{
        MyClass m;
        MyClassInitialize(&m, foo, bar);
        MyClassAddFloatAndInt(&m, 3.0f, 2);
        MyClassDoSomething(&m);
        MyClassCleanup(&m);
}

to:

{
        MyClass m(foo, bar);
        m.add(3.0f, 2);
        m.do_something();
}

Even better if they allow the use of C++ namespaces to keep a large project organized.

The other major win that comes to mind is simply being able to use powerful C++ libraries like the STL. Not having to cook up some kind of container data structure in plain C, but being able to use std::vector<SomeType> and std::map<SomeType, OtherType> and such is a huge win.

P.S. I read through much of the discussion and here was my favorite post:

http://gcc.gnu.org/ml/gcc/2010-05/msg00757.html [gnu.org]

steveha

Re:Safe subset (0)

Anonymous Coward | more than 4 years ago | (#32416344)

Well, there is already one sick part of C++ in using something as simple as namespaces and simple OOP: C++ namemangling, which is horribly spec'ed and can lead to huge problems. For example a project of the size of gcc might suffer quite a noticable slowdown on startup (dynamic linking) because of those freaky long mangled names.

Re:Safe subset (2, Interesting)

Joce640k (829181) | more than 4 years ago | (#32416410)

On the other hand ... having the compiler mangle the names for you instead of having to do it manually "MyClassAddFloatAndInt()" might be a win in the long term.

Re:Safe subset (1)

serviscope_minor (664417) | more than 4 years ago | (#32416404)

For example, operator overloading is great if used judiciously, but if used badly it can make the code a mess. And if it is used at all, then it means that you can't look at one page from a printout and know for sure what that code does; you need to look at all the class functions to make sure there aren't tricky overloaded operators.

There is nothing special about operator overloading. In any good language, you get used to thinking about operators as functions with a funny syntax. That removes all the mystery. Sure it is not good to overload everything up to the eyeballs, but one could say that in C it is easy to make millions of silly macros or functions.

Besides, GCC makes quite heave use of GMP which is the *IDEAL* candidate for operator overloading.

Re:Safe subset (1)

Skapare (16644) | more than 4 years ago | (#32416474)

Any language can be abused. GCC does that a lot with C already and it is widely known (GLIBC is worse, BTW). The issue might well just be that with this fact known, they want to avoid having that problem just get worse with C++.

Re:Safe subset (1)

Joce640k (829181) | more than 4 years ago | (#32416420)

Yes...one of the BIG wins in OO programming is that each class works like a mini namespace. It seems like a minor detail to the C++ bashers but in practice it removes a huge burden from the programmer - all function names can be short and logical.

so now I can't grep for functions (5, Insightful)

r00t (33219) | more than 4 years ago | (#32416530)

grep MyClassAddFloatAndInt *.c

grep add *.c

This totally sucks. Now I need some complicated language-specific search tool that is sure to have fewer options than grep. It's probably not even scriptable, and surely much slower. Why do you want me to suffer?

Re:so now I can't grep for functions (5, Funny)

Joce640k (829181) | more than 4 years ago | (#32416632)

Ummm... just right click the function name and select "Find all references" from the popup menu.

Operator overloading is essential (1)

Joce640k (829181) | more than 4 years ago | (#32416614)

Sure it can be abused, if you're overloading operator+ to insert records in a database you're doing it wrong.

OTOH operator[], operator*, operator-> and even operator are fundamental to data processing - you can't remove them from C++ without doing a lot of harm.

Anybody who advocates removal of operator overloading has completely missed the point - yes they can be evil but the good far outweighs the bad.

80's technology (0, Flamebait)

toolslive (953869) | more than 4 years ago | (#32416356)

C++ is 80's technology, and as such filled ugliness that was considered sexy at the time. Just like 80s pubic hairdressing it's just too much to see the essence. Try to compare Haskell's polymorphism to C++ templates and you will get the picture. Anyway, to you really think 30 years of computer science since C++ could not come up with anything better? Why not take advantage of the fact that you are very late in taking up a new technology and skip a few decades?

Re:80's technology (5, Funny)

Narishma (822073) | more than 4 years ago | (#32416522)

Yeah, exactly. I don't understand why they didn't chose something modern like Ajax.

Busted! (1)

Trivial Solutions (1724416) | more than 4 years ago | (#32416426)

So busted--false witness! Ba ha--God's right here, fucken morons. What are you thinkin! God says... files manors countenance eluding inseparable fared texts relater rude jest Whither enjoined Royalties leaves martyr Truly Jove Exodus sparedst re hay anger Enlightener fluctuating swollen materials Epaphroditus wanderer kindness goods order sips warfare easier clothed utter proclaiming nature Heal providence capacity overpass inaccurate sorrow hint material discuss garb recovered unlimited Scripture fuel actions leaps tendernesses guide slavish fallen

C, the best sub set of C++ (2, Insightful)

itsybitsy (149808) | more than 4 years ago | (#32416620)

Subject line says it all. C is the best subset of C++ there is or ever will be.

Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...