Linked by Thom Holwerda on Tue 1st Jun 2010 15:12 UTC
General Development "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."
Order by: Score:
v In other news...
by henderson101 on Tue 1st Jun 2010 15:44 UTC
v RE: In other news...
by Shannara on Tue 1st Jun 2010 16:48 UTC in reply to "In other news..."
RE[2]: In other news...
by mat69 on Tue 1st Jun 2010 16:59 UTC in reply to "RE: In other news..."
mat69 Member since:
2006-03-29

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

Reply Score: 8

RE[3]: In other news...
by Shannara on Tue 1st Jun 2010 17:29 UTC in reply to "RE[2]: In other news..."
Shannara Member since:
2005-07-06

Average ;) You notice that the voting is about 2 numbers apart.

Reply Score: 1

RE[4]: In other news...
by mat69 on Tue 1st Jun 2010 18:30 UTC in reply to "RE[3]: In other news..."
mat69 Member since:
2006-03-29

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

Reply Score: 4

RE[5]: In other news...
by Shannara on Tue 1st Jun 2010 19:51 UTC in reply to "RE[4]: In other news..."
Shannara Member since:
2005-07-06

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 ;)

Reply Score: 1

RE[2]: In other news...
by google_ninja on Wed 2nd Jun 2010 01:42 UTC in reply to "RE: In other news..."
google_ninja Member since:
2006-02-05

i voted him down because he obviously didnt read the article

Reply Score: 3

RE[3]: In other news...
by Shannara on Wed 2nd Jun 2010 01:44 UTC in reply to "RE[2]: In other news..."
Shannara Member since:
2005-07-06

I would vote YOU up, but OSNews voting system is still hosed ....

Reply Score: 1

RE[3]: In other news...
by henderson101 on Wed 2nd Jun 2010 09:27 UTC in reply to "RE[2]: In other news..."
henderson101 Member since:
2006-05-30

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

Reply Score: 2

RE[4]: In other news...
by righard on Wed 2nd Jun 2010 12:57 UTC in reply to "RE[3]: In other news..."
righard Member since:
2007-12-26

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

Reply Score: 2

RE[4]: In other news...
by lemur2 on Wed 2nd Jun 2010 14:22 UTC in reply to "RE[3]: In other news..."
lemur2 Member since:
2007-02-17

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.


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.

Reply Score: 4

Benefits
by pysiak on Tue 1st Jun 2010 16:22 UTC
pysiak
Member since:
2008-01-01

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?

Reply Score: 1

RE: Benefits
by lemur2 on Wed 2nd Jun 2010 11:57 UTC in reply to "Benefits"
lemur2 Member since:
2007-02-17

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:
Go entered the TIOBE Programming Community Index at fifteenth place in its first year, surpassing established languages like Pascal.


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

Reply Score: 2

I am confused.
by Thomas2005 on Tue 1st Jun 2010 16:28 UTC
Thomas2005
Member since:
2005-11-07

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?

Reply Score: 2

RE: I am confused.
by righard on Tue 1st Jun 2010 17:22 UTC in reply to "I am confused."
righard Member since:
2007-12-26

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.

Reply Score: 2

RE[2]: I am confused.
by tylerdurden on Wed 2nd Jun 2010 18:07 UTC in reply to "RE: I am confused."
tylerdurden Member since:
2009-03-17

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

Reply Score: 2

RE[3]: I am confused.
by righard on Wed 2nd Jun 2010 18:36 UTC in reply to "RE[2]: I am confused."
righard Member since:
2007-12-26

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.

Reply Score: 2

RE[4]: I am confused.
by tylerdurden on Thu 3rd Jun 2010 01:46 UTC in reply to "RE[3]: I am confused."
tylerdurden Member since:
2009-03-17

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.

Reply Score: 2

RE[5]: I am confused.
by sorpigal on Thu 3rd Jun 2010 11:28 UTC in reply to "RE[4]: I am confused."
sorpigal Member since:
2005-11-02

No that is not what you original comment said at all.

Except that is precisely what his original comment said. They way I read it:

I think they just want to "compliment" the GCC source that is written in C with some stuff from C++.

For example, just using std::vector can make the GCC source 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 when writing a complex application like a compiler.


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

Reply Score: 2

RE[6]: I am confused.
by righard on Fri 4th Jun 2010 12:27 UTC in reply to "RE[5]: I am confused."
righard Member since:
2007-12-26

Thank you ;)

Reply Score: 2

RE: I am confused.
by Delgarde on Tue 1st Jun 2010 22:22 UTC in reply to "I am confused."
Delgarde Member since:
2008-08-19

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++?


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.

Reply Score: 2

LLVM
by big_gie on Tue 1st Jun 2010 16:34 UTC
big_gie
Member since:
2006-01-04

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.

Reply Score: 10

RE: LLVM
by google_ninja on Wed 2nd Jun 2010 01:44 UTC in reply to "LLVM"
google_ninja Member since:
2006-02-05

c++ is a superset of c though, so it isn't really mixing languages.

Reply Score: 1

RE[2]: LLVM
by Elv13 on Wed 2nd Jun 2010 02:05 UTC in reply to "RE: LLVM"
Elv13 Member since:
2006-06-12

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.

Reply Score: 2

RE[3]: LLVM
by google_ninja on Wed 2nd Jun 2010 02:28 UTC in reply to "RE[2]: LLVM"
google_ninja Member since:
2006-02-05

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.

Reply Score: 2

RE[4]: LLVM
by siride on Wed 2nd Jun 2010 03:00 UTC in reply to "RE[3]: LLVM"
siride Member since:
2006-01-02

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.

Reply Score: 3

RE[4]: LLVM
by tylerdurden on Wed 2nd Jun 2010 18:20 UTC in reply to "RE[3]: LLVM"
tylerdurden Member since:
2009-03-17

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.

Reply Score: 2

RE[2]: LLVM
by tyrione on Wed 2nd Jun 2010 04:37 UTC in reply to "RE: LLVM"
tyrione Member since:
2005-11-21

c++ is a superset of c though, so it isn't really mixing languages.


Sorry, but Objective-C is a strict superset of C.

C++ was intended to be a better C with Classes.

Reply Score: 3

RE[2]: LLVM
by Timmmm on Wed 2nd Jun 2010 08:52 UTC in reply to "RE: LLVM"
Timmmm Member since:
2006-07-25

c++ is a superset of c though, so it isn't really mixing languages.


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

Reply Score: 2

v RE: LLVM
by chris_l on Wed 2nd Jun 2010 02:45 UTC in reply to "LLVM"
RE[2]: LLVM
by big_gie on Wed 2nd Jun 2010 02:57 UTC in reply to "RE: LLVM"
big_gie Member since:
2006-01-04

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!

Reply Score: 2

So what?
by theosib on Tue 1st Jun 2010 16:47 UTC
theosib
Member since:
2006-03-02

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.

Reply Score: 4

RE: So what?
by bnolsen on Tue 1st Jun 2010 17:02 UTC in reply to "So what?"
bnolsen Member since:
2006-01-06

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

Reply Score: 5

RE[2]: So what?
by mat69 on Tue 1st Jun 2010 19:10 UTC in reply to "RE: So what?"
mat69 Member since:
2006-03-29

Indeed. That is also what the original thread starter suggests later on:


I think we've decided to switch, but we haven't decided to what subset of C++ we're switching. I think that we want what might be called the "syntactic sugar" subset. For example, single inheritance to replace our C-style inheritance, constructors/destructors to replace explicit calls to required initialization/finalization functions, and member functions to implement ADTs, namespaces to save us some typing.

None of these things impacts memory use, or run-time performance.
Generally speaking, these are things that remove lines of code, help to prevent mistakes made by casting or forgetting to obey requirements of APIs, and make it easier to replace particular components without impacting large parts of the rest of the source code.


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.

Reply Score: 2

RE[2]: So what?
by google_ninja on Wed 2nd Jun 2010 02:36 UTC in reply to "RE: So what?"
google_ninja Member since:
2006-02-05

- 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 :-)

Reply Score: 1

RE: So what?
by Morty on Tue 1st Jun 2010 17:41 UTC in reply to "So what?"
Morty Member since:
2005-07-06

If you don't know what you're doing, your C++ code will have miserable performance.


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.

Reply Score: 5

RE[2]: So what?
by Delgarde on Tue 1st Jun 2010 23:38 UTC in reply to "RE: So what?"
Delgarde Member since:
2008-08-19

Since they are writing a compiler, hopefully they know what they are doing and also know the language.


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

Reply Score: 2

RE: So what?
by vivainio on Wed 2nd Jun 2010 19:11 UTC in reply to "So what?"
vivainio Member since:
2008-12-26

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

Reply Score: 3

RE[2]: So what?
by theosib on Wed 2nd Jun 2010 20:47 UTC in reply to "RE: So what?"
theosib Member since:
2006-03-02

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

Reply Score: 2

v Now they start to mix languages
by usr0 on Tue 1st Jun 2010 19:21 UTC
Ravyne
Member since:
2006-01-08

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.

Reply Score: 2

Neolander Member since:
2010-03-08

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

Reply Score: 3

Ravyne Member since:
2006-01-08

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.

Reply Score: 2

Neolander Member since:
2010-03-08

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

Reply Score: 2

how will this affect end users?
by hussam on Fri 4th Jun 2010 11:18 UTC
hussam
Member since:
2006-08-17

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?

Reply Score: 2