Live data from Hacker News

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

marcmutz.wordpress.com

21–29 of 29 posts

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

#21

Earlier quoted context omitted.

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 fi…

About variable length arrays: Scott Meyers pointed out that this code std::vector a; // n is a runtime argument has no real meaning in C++. Also std::vector and std::array already cover the use case.

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

#22

Earlier quoted context omitted.

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 fi…

Thank you for your helpful response!

C has an unfair advantage in this regard, but it's just not that hard to integrate C++ and C.

This is very true... as you pointed out C is very primitive in a lot of respects, and this doubtless simplifies working with it from other languages. The question is, how do I easily call the new C++11 code from something like Lua, Java, Python, Ruby, etc.? How weird will my wrapping code end up looking?

I'm sorry to harp on this, but I'm in the middle of a medium-size engine codebase written in C++, and even with our restraint so far on the use of some of the more advanced language features, things like smart pointers and whatnot are so useful that they become a concern (multithreaded code without smart pointers is a recipe for madness).

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.

Out of curiosity, how much have you done with OpenGL/OpenAL/OpenCL, etc.? Have you had any issues there yet? I'd like to know if that stuff fits okay with C++11.

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

#23

Earlier quoted context omitted.

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 fi…

Thank you for your helpful response! C has an unfair advantage in this regard, but it's just not that hard to integrate C++ and C. This is very true... as you pointed out C is very primitive in a lot of respects, and this doubtless simplifies working with it from other languages. The question is, how do I easily call the new C++11 code from something like Lua, Java, Python, Ruby, etc.? How weird will my wrapping code…

The question is, how do I easily call the new C++11 code from something like Lua, Java, Python, Ruby, etc.? How weird will my wrapping code end up looking?

Well, no weirder at least than the older C++. Which is certainly a matter of perspective! :-)

In the ideal case, someone will write a C++ binding to your language that's even easier than C. Like I said, some people love Boost.Python but I haven't tried it.

I did play with Lua and C++ recently. The Lua interpreter itself can be compiled as C++! It will then throw C++ exceptions instead of using setjmp/longjmp, which is much saner IMHO. (I am really impressed with Lua.)

Just a feeling, but I bet that sooner or later somebody is going to come along and do something really cool with C++11 lambdas and that multi-language bindings problem.

I'm sorry to harp on this, but I'm in the middle of a medium-size engine codebase written in C++, and even with our restraint so far on the use of some of the more advanced language features, things like smart pointers and whatnot are so useful that they become a concern (multithreaded code without smart pointers is a recipe for madness).

Yeah. How does one code without smart pointers in their toolkit? I couldn't go back..(except when I have to thunk back to C for something).

Also, for multithreaded stuff, I'm getting addicted to the new std::atomics in C++11!

Not new with C++11, but have you tried Boost.ASIO for multithreaded IO? It is awesome.

Out of curiosity, how much have you done with OpenGL/OpenAL/OpenCL, etc.? Have you had any issues there yet? I'd like to know if that stuff fits okay with C++11.

I have, in fact, been doing some experiments with C++ and OpenGL in my spare time. Made some wrapper classes for compiled shaders and buffer objects and the like.

I had much of that code running before I switched to G++4.6.0 and starting allowing myself to depend on C++11 features, but I know I've extended it some since. I really don't recall noticing any difference in the switch.

One of the biggest advantages of C++ is something that many people miss. Much of that "ugly" complexity is in support of some design principles that are critical for large-scale software development: backwards compatibility (often back to C), and you don't pay for new features you don't use.

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

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

That Apache one looks like it is a comparison matrix, which is extremely handy.

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

#25
post #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.

I know which companies do. I chose not to support them for my software. There are enough other companies to make money without it.

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

#26
post #6

I want to completely agree with this guy, I really do. But Visual Studio 2010 supported more of C++11 then most other major compilers (except I think for Comeau and GCC) when it was released. Apple didn't choose Clang over GCC for political reasons, a lot of Clang devs are actually on the Apple payroll.. and Clang is just a far superior compiler to GCC architecture-wise -- it just needs a few more years to catch up t…

> Apple didn't choose Clang over GCC for political reasons, a lot of Clang devs are actually on the Apple payroll.. and Clang is just a far superior compiler to GCC architecture-wise -- it just needs a few more years to catch up to full C++11 support.

Do you have any insider knowledge of this? Because the prevailing wisdom around the net is that Apple didn't like to be dependent on a GPL3'd product (which gcc became at some point), so they propped up the only viable alternative at the time, which was LLVM.

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

#27
post #25
post #15

Earlier quoted context omitted.

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.

I know which companies do. I chose not to support them for my software. There are enough other companies to make money without it.

You could do that, or based on what the author of the article was saying, you could just charge more for anyone that wanted Windows 2000 support.

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

#28
post #26
post #6

I want to completely agree with this guy, I really do. But Visual Studio 2010 supported more of C++11 then most other major compilers (except I think for Comeau and GCC) when it was released. Apple didn't choose Clang over GCC for political reasons, a lot of Clang devs are actually on the Apple payroll.. and Clang is just a far superior compiler to GCC architecture-wise -- it just needs a few more years to catch up t…

> Apple didn't choose Clang over GCC for political reasons, a lot of Clang devs are actually on the Apple payroll.. and Clang is just a far superior compiler to GCC architecture-wise -- it just needs a few more years to catch up to full C++11 support. Do you have any insider knowledge of this? Because the prevailing wisdom around the net is that Apple didn't like to be dependent on a GPL3'd product (which gcc became…

That may be so (and I'm not an Apple insider, although I do know a few LLVM devs). I guess you could say a driving motivator to find an alternative solution to GCC was to not be reliant on a GPLv3 license. Traditionally I don't think the license has stopped Apple from contributing a lot back to the OSS community (just look at WebKit).

Besides, a compiler is just a compiler. Maybe someday down the road they will start producing their own ISA, but until then even if they're making their own ARM chips it's really hard to get it to do special Mac/iPad-only magic.

What I do know is that Clang was funded by Apple almost from the start, it was engineered right from the start to be more than just a compiler but something you could plug into the IDE as well (as the latest XCode demonstrates, it has completely unbeatable C insight).

LLVM itself is also far more extensible than GCC, just look at the slew of new-ish (last 3-4 years) of projects that have launched using LLVM. Have you heard of any such projects being launched with GCC? I can't think of any (maybe if they did, they weren't proud of it).

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

#29
post #28
post #26

Earlier quoted context omitted.

> Apple didn't choose Clang over GCC for political reasons, a lot of Clang devs are actually on the Apple payroll.. and Clang is just a far superior compiler to GCC architecture-wise -- it just needs a few more years to catch up to full C++11 support. Do you have any insider knowledge of this? Because the prevailing wisdom around the net is that Apple didn't like to be dependent on a GPL3'd product (which gcc became…

That may be so (and I'm not an Apple insider, although I do know a few LLVM devs). I guess you could say a driving motivator to find an alternative solution to GCC was to not be reliant on a GPLv3 license. Traditionally I don't think the license has stopped Apple from contributing a lot back to the OSS community (just look at WebKit). Besides, a compiler is just a compiler. Maybe someday down the road they will start…

> Traditionally I don't think the license has stopped Apple from contributing a lot back to the OSS community (just look at WebKit).

GPL3 makes a world of difference (KHTML/WebKit is GPL2 if I'm not mistaken); e.g., it may interfere with Apple's executable signing policy

> Have you heard of any such projects being launched with GCC?

Not as many as LLVM, but ... GCCXML, GCC Go frontend, GCC D frontend. Things still happen in GCC world.

Post reply on HN