11 ms·
GCC switches from C to C++
- twoodfin 14y agoA useful discussion of the conversion and its motivation in the GCC Wiki: http://gcc.gnu.org/wiki/cxx-conversion http://gcc.gnu.org/wiki/cxx-conversion
- akkartik 14y agoAlso interesting to see how the style guide has changed: http://gcc.gnu.org/wiki/CppConventions http://gcc.gnu.org/wiki/CppConventions; http://gcc.gnu.org/codingconventions.html http://gcc.gnu.org/codingconventions.html
- Paul_S 14y agoThe "Spelling, terminology and markup" section is a bit painful. Does anyone really keep it printed and stapled to the wall in case they write non-zero rather than nonzero? Seems really petty. I hope the enforcement is done by simply running a regexp or ignored altogether. Code is where conventions are important, within comments I really wouldn't be upset if someone called Objective-C "Objective C".
- scott_s 14y agoThat's standard stuff for any organization that makes documents - keep in mind that the primary purpose of the list is for documentation and user-visible messages. The NY Times surely has a similar kind of list. Do you think that would be equally as painful?
- Someone 14y agoEvery decent paper has one; the NY Times is no exception. http://www.amazon.com/York-Times-Manual-Style-Usage/dp/0812963881 http://www.amazon.com/York-Times-Manual-Style-Usage/dp/08129.... 384 pages.
- jlgreco 14y agoThere are entire books written about those sort style details. Personally I find it comforting in a strange sort of way to know that there are rules out there that I can follow if I wish.
- emelski 14y agoHere's the rationale from that document: * C++ is a standardized, well known, popular language. * C++ is nearly a superset of C90 used in GCC. * The C subset of C++ is just as efficient as C. * C++ supports cleaner code in several significant cases. * C++ makes it easier to write and enforce cleaner interfaces. * C++ never requires uglier code. * C++ is not a panacea but it is an improvement. It's interesting to me how defensive many of those justifications are. "It's just as efficient!" or "It's just a superset anyway!" Not until halfway through the list do we get any real description of expected benefits: C++ makes it easier to write and enforce interfaces, and C++ supports cleaner code in several significant cases. The last item is the most telling though: it's clear that these developers feel they've hit a point of crisis, and they are willing to take risks like this in order to lift themselves out of the problem.
- reacweb 14y agobuild change to require a C++ compiler is a no go. One of the reasons to install gcc on a machine is the absence of a descent C++ compiler. 20 years ago, the C compiler of Sun was completely broken and we were happy to have gcc.
- twoodfin 14y agoIn my experience, a modern version of gcc is extremely difficult to bootstrap on anything but a fairly modern platform (e.g., I was having a hell of a time getting it going on HP-UX 11.23 with a ~2006 compiler). That's not a criticism of gcc. I'm only suggesting that if your platform lacks a modern (read: C++03-compliant) C++ compiler, you were probably already out of luck trying to get 4.7 bootstrapped.
- billpg 14y agoYou could still use the older GCC? Sun's CC -> Old GCC -> New GCC
- tzs 14y agoIt's not 20 years ago. Nowadays pretty much everyone has access to a Windows or Linux PC, or an OS X Mac, and so has ready access to good compilers. The way you'd handle that Sun nowadays is to build a cross compiler for Sun on your Windows or Linux PC or your Mac, and then use that to build the compiler for your Sun.
- 14y ago
- kingmanaz 14y agoIt will be interesting to see the OpenBSD project's response to this.
- dchest 14y agoWhy? They use older version (under GPL2) anyway: 4.2.1 and 2.95.3.
- dmm 14y agoOpenBSD has been using their own fork of GCC since the switch to GPL3. They still use the last version on GPL2, 4.2.1. Later versions of GCC are available as packages or ports but they aren't included in the main system.
- kingmanaz 14y agoI wouldn't be surprised if the folks at the project abandoned their branch of gcc in order not to be "tainted by association". There is a revulsion to C++ that is close to the core to OpenBSD's philosophy. Perhaps pcc or clang will get more attention.
- eru 14y agoBut isn't LLVM written in C++, too?
- arturadib 14y ago"What would Linus do?"
- dkersten 14y agohe would call people stupid
- gnarbarian 14y agoHe is right most of the time though.
- parfe 14y ago>>we'd have to get used to using auto_ptr >auto_ptr is broken. We should use shared_ptr instead It has begun! One of the most enjoyable features of C++ is the arguing over which parts of the language should be allowed.
- Paul_S 14y agoI avoid both but how is auto_ptr broken?
- milliams 14y agoLack of move semantics.
- Locke1689 14y agoauto_ptr's copy is broken, so if you copy one the first object loses the reference. Also, it always uses delete on the reference, which means it can't be used for things that don't use delete (like arrays which use delete[]).
- defap 14y agoBefore the days of std::move, auto_ptr's copy modeled an ownership-transfer semantic in a more efficient way than could be accomplished by shared_ptr (no refcount churn). It wasn't broken; one must have simply known when it was appropriate to use. Consider a helper function that returns a heap-allocated object and think whether auto_ptr or shared_ptr better modeled the function's intent of giving ownership of the object to the caller.
- shrughes 14y agoThe problem with auto_ptr is that it put these ownership-transfer semantics in the copy constructor instead of something more explicit. A scoped_ptr type that has a release() method is far more useful and safer than auto_ptr.
- 14y ago
- duaneb 14y agoWow, I honestly never thought I'd see the day.
- thefooest 14y agothis is apalling. The argumets seem to boil down to "I don't like VEC and how hash-tables are done". Oh and the usual bs about interfaces. The result is that now there is a monstrous dependency (a c++ compiler) in place of something that an undergrad can build for a class (a basic C compiler). I wonder what rms thinks of this. Too bad he is not calling the shots in gcc anymore.
- klodolph 14y agoIt would take a smart undergrad a bit of hand-holding to write a C complier in say, less than a year. (If you can write a C compiler, you should probably be in the Masters' program.)
- lmm 14y agoA nonoptimizing C compiler is pretty easy (a friend of mine wrote one in high school), and that's all you need to bootstrap GCC. He didn't even finish his parser for C++ though.
- duaneb 14y agoStrictly speaking, C++03 can't be parsed, only interpreted (into a typed AST); it is not a context free grammar.
- klodolph 14y agoYou can parse languages that are not context-free. "Parse" just means that you figure out the structure of the file, the word has nothing to do with the techniques used.
- Jach 14y agoMany CS undergrads have a compilers class or section of a class for a single semester in either the freshman or sophomore year. Compilers for simple languages like C (simple in an objective sense, mind you) are easy once you understand a few basic concepts. Compilers in general are fairly easy, what's hard is optimization. See for instance this division optimization: http://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html http://ridiculousfish.com/blog/posts/labor-of-division-episo... That's just one clever trick, imagine going through a similar amount of work for dozens of different tricks.
- yason 14y agoThe demise of gcc has begun. Not because I don't particularly like C++ but because the folks actually have an interest to gradually start moving a C codebase into C++ as if they didn't have better things to do. Sure, some syntactic things will look cleaner (let's just exclude those that will look uglier for the sake of fairness)--in five years or whenever their transition could be considered complete.
- helmut_hed 14y agoI would regard attempts to more aggressively refactor a 30-year-old codebase as a sign of health, rather than the opposite. A sick project gets only hacks to overcome the fire du jour.
- klodolph 14y agoThe GCC folks are feeling the pressure from Clang/LLVM, which is a good thing. Under the guidance of the FSF, GCC has intentionally tangled the front end with the back end. The purpose of this was to make it hard to modularize GCC, because if GCC were modular, then you could write a proprietary component for it (like you can write proprietary Linux modules). Their goal here is to make it easier for new developers to write their own passes or front ends or whatever. GCC may be more mature, but Clang/LLVM are way easier to dive into.
- ninjin 14y ago> Under the guidance of the FSF, GCC has intentionally tangled the front end with the back end. The purpose of this was to make it hard to modularize GCC, because if GCC were modular, then you could write a proprietary component for it (like you can write proprietary Linux modules). Surely you must be joking... do you have a reference for this? Sure, I sometimes the motives of the FSF but this would be quite outrageous from a software engineering perspective.
- mansr 14y agohttp://gcc.gnu.org/ml/gcc/2000-01/msg00572.html http://gcc.gnu.org/ml/gcc/2000-01/msg00572.html