3
  1. I'm a Python2 developer and I just ordered The C++ programming language, 4th edition, from Bjarne Stroustrup's, to learn C++11. But right after I ordered it, I started to wonder if I made a mistake. Are the changes made to C++ in C++11 analogous to how Python moved from 2 to 3 insofar as code significantly breaking and not being backwards compatible? Or is learning C++11 safe to do?

  2. If I coded C++11 in XCode, the latest version being whatever it is, would it work on say a Windows machine? Or does that depend more on what will compile the code, fairly certain that XCode uses LLVM.

  • Breaking changes in C++11 and C++11 compiler support (yes, that's entirely up to the compiler and standard library implementation). – Mat May 22 '13 at 17:10
  • 2
    C++11 is largely backward compatible. Of course, it is still to be seen if developers are going to adopt the new features or not. A big part of the Python community is still using Python 2. – Giorgio May 22 '13 at 17:12
12

C++11 is both more and less disruptive than Python 3000.

It is less disruptive since it contains fewer breaking changes and those breaking changes are rarely encountered.

It is more disruptive in that it will pretty significantly change the way code is written and systems are designed in C++. Programs in Python 3 are mostly written the same way they were in Python 2. The breaking changes are mostly cleanup, like getting rid of old-style classes. C++11 OTOH contains some features that can quite drastically change the way you write code: for example, the combination of a memory model, standard library concurrency primitives, lambda literals and type inference allow for syntactically and conceptually lightweight high-level concurrency in the style of Clojure or Haskell.

| improve this answer | |
  • +1: I agree that the changes in C++ are quite disruptive. I wouldn't have been surprised if they had chosen a new name for the language. It will be interesting to see how the C++ community reacts to this new language. – Giorgio May 23 '13 at 10:56
  • 3
    Is the world ready for a language called C+=2? :) – Jack V. May 23 '13 at 14:35
8

There are certain features from C++98/03 that are deprecated, such as auto_ptr, the 'register' keyword, etc. But for the most part if your code compiled under C++98 it will be fine for C++11. The only breaking changes are the new keywords (and the re-using of the auto keyword.) So, unless you wrote C++98 code that used statements like

auto int x = 5; // auto means "on the stack"

or used the keywords 'decltype' or 'nullptr', etc. as variable names, your code should be fine under C++11.

EDIT: As mentioned there are more breaking changes, but they won't trip up the average C++98 code base. I remember hearing a story about how they chose the keyword 'auto' for type deduction (can't vouch for it being true): they did a count of every time the keyword appeared in many large code bases and determined that the C 'auto' keyword went basically unused. Case in point: they take backwards compatibility very seriously.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.