Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
  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.

share|improve this question
    
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

2 Answers 2

up vote 11 down vote accepted

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.

share|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

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.

share|improve this answer
    
Thank you. Just to clarify my position some more, when I started learning python, people told me to learn 2 rather than 3. But basically in this case it seems like its okay to learn C++11. –  Edgar Aroutiounian May 22 '13 at 17:13
2  
"The only breaking changes are the new keywords", not quite. But you're right it's all mostly downwards-compatible. –  Mat May 22 '13 at 17:14
    
Thanks, I added an extra blurb. –  bstamour May 22 '13 at 17:25
    
I've heard that same story of them spending a lot of time looking and only finding a handful of valid uses of auto. I can't help but feel it came from the mouth of Bjarne Stroustrup. --- Yeah, that's where I remember it from. "Several committee members trawled through millions of lines of code finding only a handful of uses -- and most of those were in test suites or appeared to be bugs." –  chris May 23 '13 at 5:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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