Slashdot Mirror


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.

12 of 406 comments (clear)

  1. Re:too bad GCC is not relevant anymore thanks to L by SharpFang · · Score: 3, Insightful

    Don't be so bold in claiming most embedded platforms are something.

    Most embedded platforms use Keil, Assembler and all kinds of various odd proprietary compiler suites that suit their 8-bit and 16-bit nature better. The elitist, narrow though visible of 32-bit ARM is using GCC.

    I assure you your refrigerator temperature thermostat was not programmed in GCC.

    --
    45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
  2. Re:Classes/Templates are not a magic bullet ... by gbjbaanb · · Score: 4, Insightful

    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.

  3. Awesome by Carewolf · · Score: 4, Insightful

    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!

  4. Re:GCC should remain small and fast by serviscope_minor · · Score: 5, Insightful

    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.
  5. Re:Classes/Templates are not a magic bullet ... by serviscope_minor · · Score: 5, Insightful

    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.
  6. Re: progress by DeathToBill · · Score: 4, Insightful

    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
  7. Re:Classes/Templates are not a magic bullet ... by serviscope_minor · · Score: 5, Insightful

    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.
  8. Re:More like "C with Classes" by swillden · · Score: 3, Insightful

    When I realized that my array of Boolean objects in C++ was an order of magnitude more memory intensive than the bit-arrays I could create in C

    Dude, std::vector<bool>. All of the iterable, dynamically-resizable, type-safe goodness of a real array type with very nearly all the efficiency (time and space) of hand management of packed bit arrays. The only downside is that you do have a little extra bookkeeping info (an int) to support the dynamic resizing. If you need to avoid even that, there's also std::bitset, which has a length fixed at compile time. Odds are that code using std::bitset will be more efficient than what you'd write, and you don't have to waste brain cycles on "keeping track of the fact that it's a pointer to a bunch of bits".

    There are some reasons to prefer C over C++, but your example is decidedly not one of them. In fact, it strongly favors C++.

    --
    Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
  9. Re:OOM inside STL by maxwell+demon · · Score: 4, Insightful

    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.
  10. Re: progress by smittyoneeach · · Score: 3, Insightful

    Which thesis clearly explains why no one uses Boost and it has zero developers, not to mention a dearth of creative ideas.

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  11. Re:Type unsafe... by jonadab · · Score: 3, Insightful

    > LISP is quite powerful and fast as a machine
    > language, it just happens to be unparsable by humans.

    What on earth are you talking about? Lisp is extremely trivial to parse. Lisp barely even has syntax.

    Now, keeping track of Lisp program flow in your head, that can be a bit tricky and can lead to some substantial maintainability issues, especially when some hotshot programmer starts throwing lambda functions around like there's no tomorrow (or, worse, continuations).

    But parsing? Parsing Lisp is dead simple. You could train an elementary education major to do it.

    --
    Cut that out, or I will ship you to Norilsk in a box.
  12. Re:Classes/Templates are not a magic bullet ... by Urkki · · Score: 3, Insightful

    For you, I suggest two-pronged approach to C++. First of all you have libraries and frameworks. They take full advantage of C++ features, but hide them. Then you have the actual application code that uses these libraries, and is much simpler, ideally readable by somebody who only knows Java or C#.

    The difference to doing the same in C is, in C you'll use macros and have poor type safety, ugly-looking code and get obscure macro related errors when when you put bad stuff as macro arguments.

    In short, the trick with C++ is, you don't use most of the features, unless you really have to. Note that you can write your current C code as C++ code, except use whatever subset of C++ features you think will make your C-like code better, and only when it actually makes it better. Limiting yourself to pure C is, IMNSHO, just stupid, unless you're coding for a small embedded system and don't want to include C++ runtime in it.