“I am pleased to report 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. Before we start to actually use C++, we need to determine a set of coding standards that will apply to use of C++ within GCC.”
.. Cows say “moo”, and dogs say “woof”.
And … it looks like script kiddies voted this down. There should be a way to report vote trolls.
Yeah, exactly. Everybody who voted himt down — including me — is a script kiddie and maybe even a “voting troll”. In my case a “vote up [excluding him] voting troll”. You got me.
PS.: I voted for “troll”, without the voting.
Edit: Oh damn, just looked at your voting records. How would you describe yourself?
Edited 2010-06-01 17:02 UTC
Average You notice that the voting is about 2 numbers apart.
No, that is not what I meant. I meant the “(28% positive moderations)” part — I thought you were refering to peopl whoe constantly vote negative as “voting trolls”. But in any case that is all OT.
Personally I think that this news is more than the initial poster implied. The single most important FOSS compiler decides to accept code in a different language after a history of more than 20 years of developement.
Not sure if it is LLVM that caused this move — competition is great — nonetheless imo it shows that the GCC team is far from standing still as was proven lately with their 4.5 release that introduced some nice features.
Edit: My English gets worse and worse. :/
Edited 2010-06-01 18:32 UTC
Ohh! I see. What I mean was, that I usually vote down, and comment why I vote down Not just vote down and leave no comment
i voted him down because he obviously didnt read the article
I would vote YOU up, but OSNews voting system is still hosed ….
For me *personally* the FSF is inane. I don’t need to read about *how* inane it is, or how it has decided it’s okay to use more modern programming paradigms. It’s all very 1990 for me.
Edited 2010-06-02 09:28 UTC
If you don’t want to read an article on Osnews, you can try and contact the person whom posted it and ask them to remove it.
Or maybe you can make some sort of deal with Osnews which hides articles the AI in Osnews’ supercomputer thinks you don’t like.
…In the worst case scenario you can install Greasemonkey for Firefox and remove the article your self.
There aren’t any other options I’m afraid.
Edited 2010-06-02 12:58 UTC
The FSF, through GNU, holds the copyright to software that is more widely used than any other code on the planet, despite the 90% market share of Windows on the desktop.
gcc is a prime example of very pervasive GNU software. gcc is the software that compiles more code for more CPUs than any other compiler, bar none. This applies particularly to embedded CPUs.
Inane to you, maybe so, but to the IT/Electronics industry as a whole the FSF is critically important. Irreplaceable.
Wondering on what benefits for the users of libraries and end users of applications would be?
Let’s say I’m using GCC for compiling a program, I’ve been coding & compiling for years now. Any changes to me or my users?
Maybe introducing new concepts to GCC would take less time? hmm, what do you think?
I think it is all about adding new languages to the collection. “gcc” is, after all, the GNU Compiler Collection.
One such new language is Google Go.
http://techcrunch.com/2009/11/10/google-go-language/
http://www.h-online.com/open/news/item/GCC-to-support-Google-s-Go-9…
http://en.wikipedia.org/wiki/Google_go
Paradigm: compiled, concurrent, imperative, structured
http://golang.org/
Go claims for itself to have the following desirable characteristics: simple, fast, safe, concurrent, fun and open source. Go is type safe and memory safe … say good-bye to stack overflows. Go has fast builds, clean syntax, garbage collection, methods for any type, and run-time reflection. Apparently, Go is gaining some level of popularity:
So how is all this in any way relevant to the topic, you may well ask?
gccgo, which is the gcc frontend program (i.e. compiler) for Go, is itself written in C++.
http://gcc.gnu.org/ml/gcc/2009-11/msg00297.html
Hence the need to allow gcc to use C++.
Edited 2010-06-02 12:09 UTC
Are they talking about writing GCC itself with C++?
Are they trying to replace current code, written in C(?), with C++ or do they want to write new code with C++?
Has GCC gotten so large that they want, or even need, to break it up and make it modular so it will be easier to update and maintain?
I think they just want to “compliment” C with some stuff from C++.
For example, just using std::vector can make the code a lot smaller, easier to understand and less bug prone.
Also constructors and destructors can prevent a lot of memory leaks.
It makes no sense not to use some of C++ improvements over C.
No, it is about allowing gcc itself to be written in C++.
C++ is already mostly a superset of C (with some caveats so it is not as strict of a superset in the mathematical sense as Obj-C is), what you are proposing makes no sense whatsoever.
Edited 2010-06-02 18:12 UTC
I actually mend that
I mean, gcc will still be written in c, with some extra c++ sugar. I didn’t mean c itself would become more c++.
Sorry if I was unclear.
No that is not what you original comment said at all.
To err is human, so no big deal. But being wrong and being misunderstood are two different things.
Except that is precisely what his original comment said. They way I read it:
Bold parts added to clarify minorly ambiguous statements.
To misunderstand is human, to put words in to someone else’s mouth is unkind, to assume that your interpretation is the only possible one is shortsighted at best.
I don’t see how any reasonable, fair person could read that original comment and think that the commenter is talking about the C language as parsed by GCC and not the GCC source code itself. I can only presume that you are unreasonable, or unfair, or stupid.
Hostilely yours,
Edited 2010-06-03 11:29 UTC
Thank you
The latter – as the article says, they’ve simply declared that C++ code is now permitted in the compiler. No great plan to rewrite everything in C++ – just the removal of a policy that disallowed it.
GCC faces strong competition from LLVM, which is written in C++. Many people prefer C++ over C, as it “feels” more modern.
This move is surely to attract new developpers. Personnally, I don’t like mixing languages in a project: it tends to be confusing. Just look at how it can be confusing to have multiple coding style in a project. Now imagine different languages…
As for the user point of view, it probably won’t change much, if nothing at all.
c++ is a superset of c though, so it isn’t really mixing languages.
But now, both C and C++, so procedural and object oriented code are going to be blended in the code, so yes, it will be 2 languages, even if one is based on the other, they share only the same syntax.
you are talking about idioms more then anything, I mean, you can do OO in C and you can do procedural in C++. I don’t think they intend to do sweeping architectural changes or anything like that. Also, anything that is valid c is also valid c++, that makes c++ a superset of c, not just based on it. You could say java is at least partially based on c++, that doesn’t mean you can compile c++ code to java.
This is no longer true. There are things that are valid in C, but not C++. I can’t be bothered to Google for the details, but I’m sure if you care you can find more than enough about that subject.
Procedural and object oriented paradigms are not mutually exclusive.
Both C and C++ are procedural languages (both in the sense of them being imperative languages, and in the sense of using procedures as the basis for modular object assembly).
In fact, almost any object oriented paradigm is by definition based on procedural approaches.
So it would be correct to say that C and C++ are both procedural languages, and only C++ is the object oriented one.
Sorry, but Objective-C is a strict superset of C.
C++ was intended to be a better C with Classes.
Not quite any more. The latest version of C has several features that C++ doesn’t – structure and array initialisation in particular.
Also, C++ has a different ABI to C so you have to add extern “C” things to all your headers…
Get real. It won’t make any real difference just like LLVM itself won’t make any real difference.
If my C code works just fine as is, what the fracking point of converting it to C++?
There isn’t any.
To appease fracking assholes like you?
Get a fracking life you wanker……
Wow… what a great post. I’ve never said _anything_ about converting code. Please learn how to read.
LLVM _is_ doing a difference right now: more competition in a free market is always good for the consumer.
And why so much hate? In the end, it’s a “fracking” compiler we are talking about, there is no life at stake!
I guess it’s vaguely interesting, but I see adding C++ to a compiler like adding C++ to a kernel: Opening up a can of worms.
I’ve read 6 C++ books cover to cover. I’m not a world-class expert, but I know a lot about how to write C++ code and deal with all of the gotchas (like defaulting to pass by value, to mention a relatively minor example). If you don’t know what you’re doing, your C++ code will have miserable performance.
The main reason to use C++ over C (which I do a lot) is the convenience of object-oriented programming. There are a lot of things that take a lot less time to write in C++, especially with some of the libraries like STL. Also, there are some great performance GAINS you can get using templates, inlining, and metaprogramming. (IIRC, the STL sort() function is said to be like 5 times faster than the glib qsort, because at compile time, it builds a template function specialized to the type you’re sorting, rather than having to make calls to a compare function through a function pointer.)
So, I guess what they’re going to get out of this is perhaps some more rapid development (but lower performance) and perhaps a few cases of improved performance.
Keep the worms under control.
Eliminate all use of macros except for platform specific only. Use inlines and simple tempate functions instead. Use namespaces based on module names. Namespace *everything*, including anonymous namespaces.
Use the functional programming part of c++ <algorithm> to great advantage. Limit template use to providing compatibility with <algorithm>.
Replace structs with class, keep struct members public as before (it’s stupid to write simple accessors for the sake of writing accessors). Avoid inheritance of any type as much as possible. Keep constructors very simple, use named “static” constructors and have “isValid” method check in every class.
Exceptions are potentially a huge black hole (what really is “exceptional?”). Getting fancy with templates is bad (reference stupid template tricks found in boost).
All in all not a bad choice. Be careful with the cannon that is C++.
Indeed. That is also what the original thread starter suggests later on:
I think this is the right way to go: Using C++ to make things easier not to make them harder.
And later on if the need for another feature arises things could be discussed again, but being conservative initially is a good thing and still provides nice possiblities.
– limit the use of clever metaprogramming only to where its needed
– use FP techniques whenever possible and appropriate
– always favor composition over inheritance, and limit inheritance hierarchies whenever possible
– use constructors to initialize the object, not as a place for logic
– have consistent validation of objects
– never use exceptions as flow control
great six points applicable to any OO programming language 🙂
Since they are writing a compiler, hopefully they know what they are doing and also know the language. Otherwise I don’t think miserable performance will be the biggest problem.
Not necessarily. Certainly, those responsible for the C++ compiler itself must know what they’re doing. But one of the reasons they’re being cautious is that many of the core developers are *C* coders, not necessarily familiar with C++.
I don’t see the equivalence. Compiler is basically a glorified data processor, completely neutral to timings and whatnot. It’s basically batch processing, something you could do in BASIC or cobol.
C++ is welcome improvement. I don’t see a C based system staying competitive with llvm for a long time. C is just much less productive, less readable and as a consequence less fun.
You’re obviously not a Gentoo user.
People have been complaining for a long time about GCC compilation speed, and they cheer every time it’s sped up. And not just Gentoo users. Anyone who runs a compile farm for some reason or other will appreciate a fast compiler. (For instance, MetroLink had a compiler farm for their MetroX server and drivers.)
C, C++ maybe a little bit of Java?
Thanks god there is the Clang/LLVM project which has been written in C++ from beginning!
C++, and in particular the new 0x features will really open up a lot of ways to cleanup the code.
C++ 0x now has lambdas, and a std::function object that contain and pass them around, as well as functor objects or C-style function pointers.
C++ 0x now has a standard regex library.
C++ 0x adds a lot to the functional programming side (unfortunately no pattern matching, though similar contructs are easy enough to create), and functional programming has long been known for its prowess in parsing and compilers.
C++ 0x adds r-value references (move semantics) which reduce the use of intermediate temporary values a great deal (one of the main complaints against C++ performance is that temporaries were created silently in the background uneccesarily.)
C++ in general adds templates, which is certainly a better alternative to meta-programming than C-style macros.
It’ll take awhile to be adopted, and they certainly shouldn’t do so wontonly, but there are plenty of advantages to be had by moving to allow C++.
Honestly though, if you’ve not been keeping up with the new features of C++ 0x or never cared about C++ before, go check it out (wikipedia has a throurough, if shallow, treatise thats pretty well done) — its nearly a whole new language.
Well, in my opinion, C++0x will add additional complexity to an already way too complex language, reducing the number of capable C++ programmers and compilers even further. But I hope I’m misunderstood.
Edited 2010-06-02 07:44 UTC
I’m with you in a lot of respects.
As a language which, at the same time, tries to be both object-oriented and a systems-language (setting aside the true multi-paradigm nature) there are unfortunately bound to be ‘dark corners’ where things are left unspecified.
Its also unfortunate that the syntax can be so unwieldy (Something closer to SPECS, at least as an option, would be very welcome IMO).
C++ is a complex language, certainly more “rules” are being added to satisfy C++ 0x, but many of the additions go a long way toward combating code complexity, and allowing code to be more concise yet more expressive (they seem to be learning a lot from functional languages, in spirit if not in implimentation).
‘auto’ eliminates a lot of redundant type specification, both inline and typedefs.
Lambdas and std::function eliminate the need for functor objects, and puts the code where it should be. (and is a decent substitute for the lack of local functions in C++).
The regex library means C++ users can largely standardize on the one library, rather than all the competing regex libraries that exist now.
C++ is definately a tough language to fully understand though — and poorer coders only understand precisely the breadth and depth that they’ve needed to — I’ve been at it for 6-7 years now, and actively study the new features, dark corners and pitfalls, but I’m only *just* approaching “expert” — if I assume that there are at least two levels above expert: ‘guru’ those that can listen to your problem, then cite (or quote) the portion of the standard that explains it from memory, and “diety” those that shape the future of the language. At my level, I’ve got a pretty good intuition when things go wrong with the core language and familiar libraries and why it is they’ve done so, and in general I know when something smells fishy even if I’ve never dealt with a certain feature or aspect before.
I can’t discuss all of that, sadly, because in C++, after playing for 2 years, I’m currently at the “beginner++”/”amateur–” level.
This always puzzles me when compared to languages like C and Python, where I got to understand the general logic in a few months and master the thing in ~1 year. In C++, anytime I finally get to understand and use a new nifty feature, I discover ten other ones which I didn’t know about before. And now, C++0x is going to add up even more features to that.
It’s discouraging.
I start to think that I’m going to end up restricting myself to using a “C with classes, overloading, complex heritage, exceptions, streams, and templates” feature set, and ignore the full complexity of the STL which is unneeded for my current projects. But I’d find it sad to do so, because if all those features are here, they certainly have some use…
Edited 2010-06-02 19:42 UTC
How will this affect end users who don’t actually develop software but simply use gcc to compile software from source? Will there be any advantages or it will be the same?