Live data from Hacker News

C++98 Support Costs Extra (or why we should switch to C++11 now)

marcmutz.wordpress.com

11–20 of 29 posts

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#11
post #7

"How many Mac applications still support OS X 10.2? 10.3? 10.4? Half of the web doesn’t work anymore on KDE 3.5′s Konqueror." I'm not familiar with the author's product and can't say whether C++11 is the right choice for him, but I wouldn't consider the constant API churn of OS X or the constant web standard and web standard extension churn to be a good argument in favor of anything.

For existing large applications (in particular, Adobe’s and Microsoft’s) OS X’s relatively quick change has been somewhat frustrating, and for any application there’s no need to replacing working code with newer different code just for the sake of it... but for new projects, OS X’s API “churn” has been great news, letting smaller teams tackle harder projects and create richer user interactions in less time.

I think it’s pretty reasonable to argue in favor of using new language features and APIs for new projects, assuming enough of the target audience is using platforms which support them.

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#13
I used C++ for years, and then switched to C#, and recently switched back to C++ in my new company (choice of language reflects only the nature of the software we develop, not language superiority). Just yesterday I was evaluating the new features of C++11, and I was pleasantly surprised by (1) the new language features, and (2) the extent of support already by existing compilers (gcc 4.4 and VC++ 2010).

I can see that we'll immediately benefit from a few improvements, such as auto variable, lambda support, standard support for unique/shared/weak_ptr. Even old school C++ users who have no interest in fancy new idioms would benefit from these "syntactic sugar" features found in other modern languages. There are a lot more that I'm still exploring, but so far I like what I saw.

Also these new features just work on the compilers. Given how long the standard process has been, a lot of the features were already baked in. Modern g++ and VC++2010 both have very good support. I listened to a BUILD presentation on C++ and the Microsoft folks are very committed to full C++11 compliance in VS11 (next version of Visual Studio), but AFAIK, VS2010 is already quite capable.

So, I agree, if you have a choice, switch NOW.

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#14

Some entertaining bits from the article: "How many Mac applications still support OS X 10.2? 10.3? 10.4?" "Then why should we be so conservative when it comes to C++, the very core of what we work with?" "C++11 is a much more productive language than C++98. We as an industry can, however, only reap that productivity gain if we stop throwing C++ productivity out of the window by the bucket-load in the hopeless pursuit…

I think your missing a key point: C++11 is a better, cleaner language. It's not C++98 with a bunch more not-fully-baked and overly complex stuff thrown in. Much of the new stuff that's added is there to make the old complexity go away. Most of the old mile-long redundant type definitions can go away now, being replaced with just the 'auto' keyword. The old std:: argument binders were like poor man's lambdas. Now we h…

The issue is that there are already many better, cleaner languages than C++98/03.

C++ is a good language, with some clunk to it. The best parts of it are arguably the bits inherited from C (which C++11 looks like it might break with). The OOPy parts (classes, polymorphism, etc.) have been done better by languages like Java, Javascript, and Smalltalk. Templates exist to get around grossness of the rest of the language, and were done better by Java's generics anyways. Multiple inheritance was done better by Java in the form of interfaces.

The rhetoric is that these changes somehow simplify the language--that's cool and all, and may even be true for the most trivial of examples or the most basic of beginners. The problem is that these new features are going to be released in the wild alongside many libraries who don't use them, being old, and who won't be updated, being cumbersome or trusted. And so, the burden of making the ends meet is going to fall on the rest of us who now have to support, in effect, two languages.

If the improvements are incremental, then this wasn't worth doing, If the improvements are such a new, cleaner, simpler language, why the hell call it C++? Again, see D.

Lastly, most of the fixes are syntactic sugar which do nothing to help fix some very real issues with the deployment of the language.

How do I bind these things to other languages cleanly? In C this is trivial--why isn't this fixed in C++11?

How do I load libraries of classes dynamically at runtime? From C wrappers?

When interfacing with old libraries (which actually do exist), how often am I going to have to write some kind of NULL-nullptr glue code?

Why do we not have variable length arrays (they're in C99)?

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#15
post #9

If your supported platform list looks like this: Windows Switch to C++11 NOW. You will kick yourself for not doing it earlier.

If you want your application to run on Windows 2000, you can't. VS 2008 doesn't have "auto" etc but it can produce binaries which run on Windows 2000. The libraries for VS 2010 simply removed the code that allowed them to run on Windows 2000. I can imagine you'll ask "who uses Windows 2000," well, if home users don't, the companies still do.

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#16
Our company's been C++0x-heavy since the first bits rolled out in GCC. We're lucky enough not to have any legacy, so we can afford this.

The other day I was stuck on a system with only a C++ (03) compiler, and it was a truly crippling experience without lambdas and the new STL.

Anecdotes aren't worth much, sure, but I find it difficult to disagree with this article.

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#17

Earlier quoted context omitted.

I think your missing a key point: C++11 is a better, cleaner language. It's not C++98 with a bunch more not-fully-baked and overly complex stuff thrown in. Much of the new stuff that's added is there to make the old complexity go away. Most of the old mile-long redundant type definitions can go away now, being replaced with just the 'auto' keyword. The old std:: argument binders were like poor man's lambdas. Now we h…

The issue is that there are already many better, cleaner languages than C++98/03. C++ is a good language, with some clunk to it. The best parts of it are arguably the bits inherited from C (which C++11 looks like it might break with). The OOPy parts (classes, polymorphism, etc.) have been done better by languages like Java, Javascript, and Smalltalk. Templates exist to get around grossness of the rest of the language…

I'm nothing like an official C++ spokesperson, but I'll take a shot at these questions.

If the improvements are incremental, then this wasn't worth doing

Well maybe C++ is not your cup of tea, but I find the improvements worthwhile.

If the improvements are such a new, cleaner, simpler language, why the hell call it C++? Again, see D.

Yeah, I think it's a better C++ not an entirely new language.

Lastly, most of the fixes are syntactic sugar which do nothing to help fix some very real issues with the deployment of the language.

Systems languages are syntactic sugar for the underlying runtime model. I consider C++ to be a systems language (the ISO spec explicitly defines a minimal profile suitable for embedded systems for example). But C is probably a slightly more "systems" of a language (in no small part because it's the language which defines most system's APIs).

How do I bind these things to other languages cleanly? In C this is trivial--why isn't this fixed in C++11?

If you think this is trivial in C I suspect it's because you have so much familiarity with it and/or these other languages are implemented in C and define their external APIs directly in C. C has an unfair advantage in this regard, but it's just not that hard to integrate C++ and C.

Sometimes C++ has advantages too, some people swear by Boost.Python for example. Looks much simpler than C to me.

How do I load libraries of classes dynamically at runtime? From C wrappers?

That's one way. The main reason dynamic loading works in C is because the types are all so primitive (and it doesn't have "classes"). You can use those primitive types for your APIs and in C too.

Another way is to define the classes interfaces in terms of something binary stable over the scope you wish to separately compile these libraries. This requires some understanding of the guarantees of the platform and complier/linker. MS-COM for example gets a lot of mileage out of some relatively minimal abstract class layout conventions.

When interfacing with old libraries (which actually do exist), how often am I going to have to write some kind of NULL-nullptr glue code?

I've been writing some C++11 with C++4.6.0 and a bunch of old libraries and haven't run into that. I don't use pointers in my code very much, so I don't think I've even had to use nullptr yet.

So I would think "not very often", at least if your coding style is similar to mine.

Why do we not have variable length arrays (they're in C99)?

I don't know why the decision was made in the language committee, but std::vector with the new initializer syntax works well for me for that purpose. Perhaps the C99 construct could be a little more efficient, but I don't see a reason that an alert compiler couldn't also allocate the storage on the stack.

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#18
post #5
post #2

And in the (rather depressing) real world, I have gotten flack in the past year for making changes to my source code that required C++98 compatibility, which made said code no longer compile on Microsoft Visual Studio 6.0.

Do they still run Windows NT4 on their dev systems, too? This is quite surprising.

No idea, and I'm kind of scared to ask.

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#19
GCC, Clang, Visual C++ 11 provide charts where they show how far they have completed c++0x support (renamed to c++11):

GCC: http://gcc.gnu.org/projects/cxx0x.html

Clang: http://clang.llvm.org/cxx_status.html

Visual C++: http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.a...

Re: C++98 Support Costs Extra (or why we should switch to C++11 now)

#20
post #19

GCC, Clang, Visual C++ 11 provide charts where they show how far they have completed c++0x support (renamed to c++11): GCC: http://gcc.gnu.org/projects/cxx0x.html Clang: http://clang.llvm.org/cxx_status.html Visual C++: http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.a...

Apache also maintains a list: http://wiki.apache.org/stdcxx/C++0xCompilerSupport

And IBM: https://www.ibm.com/developerworks/mydeveloperworks/blogs/58...

And Digital Mars: http://www.digitalmars.com/ctg/CPP0x-Language-Implementation...

Post reply on HN