GCC Switches From C to C++
According to a post on the GNU Compiler Collection list, GCC is now built as a C++ program by default. This is the fruition of much effort, and the goal now is to clean up the GCC internals that are reportedly pretty type-unsafe by rewriting them using C++ classes and templates.
Irrelevant? Not quite. For your particular use, maybe. But most Linux distros are still built using GCC, and most embedded platforms provide a GCC-based toolchain. So if, by 'irrelevant', you actually mean, 'the compiler with the most-often executed output code on earth', then yes, I guess you're right.
Slashdot - News for Nerds, Stuff that Matters, in ISO-8859-1 Has just realised that beta makes this signature redundant
No, no it does not mean anything of the sort.
How will this affect bootstrapping the GCC on bare systems?
Been a while since I've delved into LFS or the like, but I'd think GCC being C++ based would seriously complicate things as it's now got more dependencies.
No, it means when you go in and add extra functions to GCC that those would have to be GPLv3 as well, at least if you want to distribute them.
It has NO effect on what the use of the application. In fact that is has no effect on the end user is one of the topmost clause of the GPLs.
Bad code is bad code, and you can write it in any language, yes, even visual basic.net.
So the point is not so much "how useless are those lousy GCC devs who will write crappy code", but "how good are those GCC devs now they have a more powerful tool in their hands".
I'd hope they start to discover the STL too, and use the standard containers at the very least - no need to use custom ones unless you either continue to use the existing C-based ones, or you have some very specific performance issues that you absolutely cannot fix any other way (and generally, you don't have this problem with the STL)
Now, sure, I hope they don't discover cool new features like STL algorithms and start to litter the code with lamba-d functors.
I've read their guidelines, and they're doing much like I've been doing recently with moving from C to C++ for embedded systems programming, which is to avoid the really crazy shit that you can do in C++. In particular, exceptions and RTTI are absolutely verboten. They're even planning a compiler switch that turns off the features that will be outlawed in the compiler source. Any templates outside of STL are also forbidden ("template hell" sucks), and I won't even use STL myself because I can't count on having a heap. Even iostreams are being frowned on except maybe possibly in debug dump code where no text language translations are needed.
C++ can really tidy up C code that uses any sort of function pointer hooks or object dispatch style switch statements with virtual methods. A class can become a mini-API, and even used as a sort of device-driver, as in the mbed libraries. Doing this has really helped improve encapsulation in my own code.
#naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
GCC as a compiler and a community seems to really be moving, it is probably due to the competition from LLVM, but atleast for now, GCC is still the better compiler, and I wish them the best of luck.
Good compilers benefits everybody!
AIUI GCC is now GPLv3, the libraries it ships with are GPLv3 with exceptions that allow using them to build non-GPL programs. However they were paranoid about the idea that people would try and save gcc's internal state to disk and then run it through a propietry backend. So they crafted a complex exception that tries to forbid that while allowing most other combinations of gcc with propietry tools.
note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
Given a collection of developers that write difficult to understand, difficult to maintain and sloppy type unsafe code, going to C++ may not help.
It is very difficult to write easy to understand, type-safe, code in C.
The reason being that C requires so much micro-management that you end up with the code for that mixed in with the actual interesting algorithms. C++ basically makes the compiler do an awful lot of what you have to do in C anyway and does it for you automatically while keeping the details neatly out of the way.
It's also very hard to write type safe code properly in C. Just look at the classic example of the unsafe qsort versus the safer and faster std::sort.
I'd also be more optimistic if by using classes and templates they were really referring to using STL, not writing their own.
What on earth is wrong with writing your own classes and templates? They almost certainly already have a healthy collection of structs with function pointers and macros (linux certainly does have poor reimplementations of half of C++ using macros). These are best replaced with classes and templates on the whole.
That's the point. C++ formalises what everyone was doing in C anyway, making it much more uniform, easier to read, shorter and therefore much less prone to bugs.
SJW n. One who posts facts.
I used to be more polite to ignorant C++ haters. But I've lost patience.
A program written in C++ is going to be slower than an equivalent program written in C, no way around it.
There is a way around it: by not being an astonishingly incompetent developer.
And that's without even getting into features like templates, which only five people in the world understand.
Don't assume everyone is as dim as you.
SJW n. One who posts facts.
C++ is as good as dead.
Everything should be written in java, since this would give a huge speed increase.
For even more speed, programs could be run on a java interpreter, running on a java interpreter written in java.
Think of the raw speed!
I assure you your refrigerator temperature thermostat was not programmed in GCC.
That's because its CPU is a bi-metallic strip wound into a coil, and it's RAM is only one bit. The equivalent of running .configure and make is rotating a dial and tightening a screw.
Well, let's see. I personally work with control systems using x86, MIPS, PowerPC and ARM architectures, running Linux, VxWorks, QNX and WinCE (various combinations). They all have GCC toolchains, although we admittedly don't use it for CE.
If you're thinking microcontrollers, then GCC supports AVR, 68000-series, MicroBlaze, MSP430, ARM again...
Now, personally, my refrigerator has an analog thermostat, so, technically, you are right. If it had a thermostat implemented on a CPU, then I'd think there's a very good chance it was compiled with GCC.
What exactly "programmed in GCC" might mean is left for the reader to speculate on.
Slashdot - News for Nerds, Stuff that Matters, in ISO-8859-1 Has just realised that beta makes this signature redundant
I find that jerks who bitch the most are often the worst at writing code, sorry just sayin. Big ego = ass hat to work with and awful at writing code. C# might work out better for ya.
Shouldn't that be:
Big ego == ass hat
"A person is smart. People are dumb, panicky dangerous animals and you know it." - K
No, it's definitely an assignment.
"Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
C++? seriously?
That's it, I'm switching to LLVM!
You can do all kinds of nifty stuff with macros and gcc/clang extensions to provide type safety to C
Yes, I know.
You can write a GENERATE_SORT(Type, Comparator) macro which generates a sort function to work on an array of Type, using the specified comparator, and has no name collisions and is type safe using liberal amounts of ## and so on.
The point is not that you can't do them in C (you can), but the methods for doing it are ad-hoc. By moving the functionality into the compiler, C++ provides a regularity of syntax for such things that C lacks.
SJW n. One who posts facts.
No. 22 more years has seen Challenger and Columbia blow up, and we've learnt some lessons about things we should do and things we shouldn't do. Just as the Challenger investigation didn't conclude, "Ban O-rings," nobody has decided to ban parts of C++, either.
C++ is in some ways like a human language: It has an enormous range of things you can say in it. Some of them are only appropriate in certain situations. Some of them are never appropriate if you want people to take you seriously. Some of them just plain don't make sense.
So quite a lot of the development over those 22 years has been in the community learning idioms that let you use the power of C++ without hurting yourself.
Slashdot - News for Nerds, Stuff that Matters, in ISO-8859-1 Has just realised that beta makes this signature redundant
I don't write 'university code' though; and I'm not out to impress a professor or win 'elegance awards'.
I think the enormous chip on your shoulder might be obscuring your view of C++.
SJW n. One who posts facts.
http://www.boost.org/
Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
Actually the correct comparison is to not only disable exceptions in the compiler, but in addition adding hand-crafted error handling to the code. Because manual error handling also costs performance. And without error handling, your application is broken, period (and yes, I have been bitten by applications doing improper error handling. And yes, that included data loss. Loss of data stored on the hard disk, because the application didn't do any error checking when replacing the file with a new version. Fortunately I could get back most of it from the nightly backup).
The Tao of math: The numbers you can count are not the real numbers.
The GPL doesn't force you to give back. You need to have a read of it, it only forces you to "give forward".
Apple has now fully embraced clang/llvm for a couple of reasons: it was legally very difficult to for them to integrate gcc tightly with their IDE (by which I mean they would have to GPL Xcode if they linked directly to gcc); it is technically very difficult to integrate with an IDE - apparently the gcc code base is a complete mess as far as integration with other tools is concerned.
Clang/LLVM is financed by Apple and it is released under an Open Source licence. Call that parasitic if you like but because of Apple (in part) you now have a clean modern compiler toolchain that's a credible open source alternative to gcc. If nothing else, it means that the gcc dev team now have an incentive to improve their product because they have competition.
All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
Linus must be screaming inside.
Linus never allows his screaming to stay on the inside