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?
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.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
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.
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
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.