-17

Herb Sutter stated, that with the event of C++11 every single line of code in any book written before must be adapted or completely changed.

Translating this to Stack Overflow means, that at least many correct C++ answers are outdated even if they happen to be technically correct.

I think it should be possible to flag an old C++ question where this is the case and it should be possible to flag a new answer as being a C++11 cleanup. Most of the cleanups will of course be just about replacing old with uniform initialization or about replacing typedef with using.

Such flagging may then have many effects. In addition, to allow searching for flagged questions/answers it should be possible to maybe also mask the answers so only up to date answers are visible. Maybe it would be helpful to adapt the reputation system to incentivise flagging and cleanup-answering.

As things are now, users new to C++ will get quite confused with the different styles of writing C++. Many old questions and answers are still often viewed and thus important but completely forgotten by the Stack Overflow community and thus not maintained.

UPDATE I want to raise attention to a c++ specific issue and start a discussion on how old answer threads can be improved. I completely agree with the complainers here that editing an answer itself should only be done in very rare cases, for e.g. if the only thing to do is x() -> x{}.

I am not even trying to push forward a specific solution. What I would have liked to push through however is to tag this question as c++ specific thereby to restrict the audience.

16

StackOverflow is not a book. We don't teach C++11, we answer questions.

  1. Questions should never get edited to incorporate new technology. The asker defined the scope of the question, which should not get "updated".

  2. Answers should not get edited to update new technology, unless the technology is equal or better in every aspect, including but not limited to: runtime speed, memory usage, availability. Many C++ answers "updated" to C++11 become useless to many users, because they are building using compilers not supporting C++11. This is often not their choice, so you can't force them to build using C++11 support.

Nothing stops you from adding new answers to old questions decribing a better solution with C++11.

|improve this answer|||||
  • 1
    I think this depends on the editing. Editing an existing answer to add a C++11 solution seems fine to me. I agree about editing an existing answer to replace the existing answer with a C++11 version though--shouldn't be done. – Jerry Coffin Nov 3 '13 at 4:50
  • @JerryCoffin Isn't adding another answer meant for adding a solution, rather editing existing answers? – orlp Nov 3 '13 at 4:54
  • Perhaps those who spend more time on meta will have better ideas on that than I do, but I've edited C++11 code into some of my existing answers, and don't see anything wrong with doing so. I might consider adding an entirely new answer in a case where C++11 provides an entirely new/different method than the existing one, but don't see much point in a whole new answer for changing int x(1); to int x{1};. – Jerry Coffin Nov 3 '13 at 4:56
  • 2
    @JerryCoffin editing your own post to add the C++11 version of the same solution sounds reasonable. But adding a completely different solution to take advantage of C++11 features seems like it should be a 2nd answer. And generally speaking, the community does not support editing other people's answers to add new stuff, so a new answer is probably the better route to go if you aren't the author of the original answer. – psubsee2003 Nov 3 '13 at 8:40
  • @nightcracker +1 nice answer. Adding, who on earth is going to do this with 6 million questions and 11 million answers? – James Nov 3 '13 at 11:50
  • One remark to point 2. I very much encourage everyone writing code for pre C++11 compilers to think C++11 and then retrofit their writing to what makes their compilers happy. – user232310 Nov 3 '13 at 16:00
  • One remark to nothing stops you from adding a new answer. That is correct and I actually do exactly that. I get zero rep and believe it or not I am very happy with that too. However a new user interested only in the new version will probably never see my answer. Hence I may be the only one doing such an in vane effort to improve an old answer thread. – user232310 Nov 3 '13 at 16:05
1

As things are now, users new to C++ will get quite confused with the different styles of writing C++. Many old questions and answers are still often viewed and thus important but completely forgotten by the Stack Overflow community and thus not maintained.

C++, in it's core, hasn't changed much. Sure, you can say that C++11 gives programmers new tools to write programs, but the programs written in C++ can be run as well now as they ran before C++11.

Solutions are just that: possible solutions. In the real world, there hardly is a single, one-size fits-all solution. So, instead of caring whether the existing answers are properly written for C++11 we should be caring whether they are good solutions, that actually solve the problem the OP asked.

This being said, new questions that don't specify that they want a C++11 based solution can and should be answered in a way that actually solves the problem.

I think it should be possible to flag an old C++ question where this is the case and it should be possible to flag a new answer as being a C++11 cleanup.

Like I said previously, what cares is the wellness of the solution, not that it is good code. Besides, that kind of system can have several drawbacks:

  • Who would flag the questions? What would be the criteria?
  • No one is forced to rewrite the posts to conform with C++11.
  • The posts' code might stop working for earlier versions of C++.
  • What if the changes actually worsen the code?
|improve this answer|||||
  • I think these are mostly good questions. To answer the two last, I think it is a good solution to not edit any answers at all for this purpose but only add new ones. You are right that C++ has not changed much in its core. This is also because C++11 merely reflects the very big language changes in the last years kicked of by Dave Abrahams and the Boost Team and Alexandrescu and many many more. In other words, C++11 is a name that stand for a huge change. – user232310 Nov 3 '13 at 15:53
0

Many C++ programmers won't be using C++-11 for years to come. So all the questions and answers here will be perfectly valid for a good long time.

|improve this answer|||||

You must log in to answer this question.