41

After years in C#, I'm learning C++, and naturally I often turn to Stack Overflow to help me figure out how to do things.

Many common Stack Overflow C++ questions have answers from the site's beginning in 2008. These naturally come up first in Google since they have the most links by now, nine years later.

Since then, C++11 and C++14 have come out, and C++17 is right around the corner. The best way to do something in C++ in 2008 might not be the best way anymore. Stack Overflow might be producing a lot of C++ novices who are writing bad C++ (in ways that used to be good C++, but are now obsolete).

As a C++ novice myself, I don't yet have the aptitude to tell when an answer is recommending an obsolete approach. I fear that if I write a question and ask for a better way, I'll get the dreaded "This question already has an answer here" closure. I've seen the suggestion of offering a bounty on the original question, but I don't have the experience to know whether the answer actually is outdated.

What can be done about this problem so that Stack Overflow remains a great Q & A site for C++ instead of a repository of outdated information?

26
  • 31
    Add new answers using the new functionality of the later, updated versions? Commented Oct 28, 2017 at 16:31
  • 7
    It's incredible how easy people miss that solution @MartinJames. Often defaulting towards asking the same question but "for version X", which seems to forget that questions on SO should be timeless, since a repository that doesn't serve future readers is the exact opposite of SO (also clutters search results).
    – Braiam
    Commented Oct 28, 2017 at 17:03
  • 9
    @MartinJames, as I mentioned, I'm just learning C++. I'm not in a position personally to add better answers. I don't even know whether better answers are needed. I'm not in a position to know that yet. That's the problem: Can I trust this answer from 2008, or is it obsolete in 2017 after 2 or 3 new versions of C++?
    – Ryan Lundy
    Commented Oct 28, 2017 at 17:07
  • 28
    Keep in mind that "outdated" information is still relevant for those using older compilers (often in corporate environments where the risk of new compiler bugs is judged to outweigh the benefit of upgrading). It would be fair to update old answers to say "this works in C++03" or similar, as that's now a feature of the answer for some readers. Commented Oct 28, 2017 at 20:45
  • 4
    @Kyralessa Do you want to know what you, personally, can do as a C++ beginner? Or do you want to know what the C++ experts who answer questions can do? Understandably, suggestions would be very different depending on which option you mean.
    – TylerH
    Commented Oct 28, 2017 at 23:44
  • 3
    What anyone that can't offer a better answer can do is to just place a bounty. What anyone that can offer a better answer is just post it. I don't see how complex it can get @TylerH?
    – Braiam
    Commented Oct 29, 2017 at 1:25
  • 2
    @TylerH well, that would be reinventing the wheel, since bounties are specifically designed to solve that problem on one hand. And why not rely on a expert to verify/curate the information on those questions? After all, they can do absolutely anything, they are experts.
    – Braiam
    Commented Oct 29, 2017 at 1:40
  • 2
    @Braiam No, those are the only options that you can think of. There is a difference. Let other folks try their hand at a problem; more heads are better than one for brainstorming ;-)
    – TylerH
    Commented Oct 29, 2017 at 2:48
  • 16
    "As a C++ novice myself, I don't yet have the aptitude to tell when an answer is recommending an obsolete approach" - that surprises me. Stack Overflow is not here to teach you C++, it is merely a resource to fill in some gaps. The other quality sources of information you're using to study and learn C++ should be providing the necessary insight to be able to judge the relevance of questions on Stack Overflow. A really good resource also talks about history and prepares you to be able to separate the good from the bad.
    – Gimby
    Commented Oct 30, 2017 at 15:08
  • 2
    Most search engines allow you to set a date range, that's how I usually avoid the issue.
    – user1228
    Commented Oct 30, 2017 at 15:42
  • 6
    C++17 standard has been finalized since summer, and its features are already implemented as part of GCC and clang. For all intents and purposes, it is already "out"
    – Krupip
    Commented Oct 30, 2017 at 20:39
  • 2
    This is kind of an interesting question. There are some people, like me, who would be willing to provide updated answers to old questions. However, I stumble across such questions at a time I could do so only every now and then. If there was a list of "questions that might need updated answers", I'd probably be able to go through a few here and there, checking whether the advice in the answers are up-to-date, posting answers if they aren't.
    – Justin
    Commented Oct 30, 2017 at 21:42
  • 2
    Perhaps mark answers with their C/C++ dialect? I work in safety-critical software, and updating to a newer compiler or other tool is a highly controlled process that may not happen for years. Commented Oct 30, 2017 at 21:42
  • 3
    this seems to be a problem in general with SO, and not with C++ in particular. Commented Oct 31, 2017 at 9:19
  • 3
    @Braiam because they were valid at the time and, if I use an older API version, they work fine. I have, on occasion, edited some answers to add a disclaimer that they are obsolete as of [insert API version here], so that people know and don't waste their time. Commented Oct 31, 2017 at 12:01

2 Answers 2

19

The obvious answer to this problem is that the problem does not exist, because new, up-to-date answers will be added to old questions. I agree with you that this is sometimes not quite how it works.

This is probably because posting new answers to old questions is not as motivating as answering new questions, at least rep-wise. It's also not directly helping someone, the question asker is usually long gone. There surely are people motivated enough to post really outstanding answers to old questions, kudos to them! This will however happen more often for interesting, important and/or popular questions, so on average I think the chances of a new question getting an up-to-date answer are better than for an old question.

Adding a bounty to the old question is surely a very effective way to get new answers. You could afford many bounties, but not everyone can, and since up-to-date answers Make the Internet Better, it would be preferable if this could happen without someone having to invest in a bounty.

I hope the following is possible:
Post a new question, tag it with C++11/14/17, and link to the old question. Say that you think there must be a better solution with the modern language. The more hints you find that the old answers are outdated, the better.

The purpose of the duplicate closure tool is to prevent the same questions being posted over and over and over again.
It would be misused, in my opinion, if it would prevent re-posting a question once, if the old question has only been answered with C++03 and older code, since that does no harm, but the opposite. If good answers are posted, a link from the old question to the new one could be added. It's also not unheard-of that an old question may be closed as a duplicate of a newer question, depending on quality.

11
  • 1
    "Post a new question" this is a terrible advice since now the future reader will have crapton of similar yet not the same questions on the search results, instead of a single curated resource.
    – Braiam
    Commented Oct 31, 2017 at 2:51
  • 2
    @Braiam "Single curated resource" doesn't fit well into the Q&A model. And the drawbacks are well balanced by advantages: 1)post dates and/or tags are prominent enough to clearly see which question applies to what. It's even better if they link to one another - you'll clearly see others in the "linked questions" section. 2)with multiple posts, each one contains no noise i.e. no information that doesn't apply to you. 3)you can specify tags (in square brackets) as well as keywords in SO search. Commented Oct 31, 2017 at 3:10
  • 2
    @ivan_pozdeev you really are saying that? The freaking Q&A model is based on a single curated question with all possible answers! How are there even people that agree with that idea? SE has been trying since a while to encourage exactly this.
    – Braiam
    Commented Oct 31, 2017 at 10:04
  • @Braiam That vision failed miserably. I showed how relevant, but still different, situations apply themselves nicely to the existing model. Generally speaking, different software versions is no different to other "close but distinct situations" cases here. So I have just as much, if not more, right to say that this is the "true Q&A model". Commented Oct 31, 2017 at 10:07
  • 1
    There have been 4 solutions proposed in the question you linked, @Braiam. How many of these have been implemented? Zero. But I agree that posting new answers to old questions should be encouraged, of course.
    – alain
    Commented Oct 31, 2017 at 10:12
  • 2
    Absolutely. If the version of the language changes in such a way as to invalidate the original answers, then it becomes a new question. The duplicate closure system already handles this perfectly well: if there are no salient changes, then it's a duplicate; if there are salient changes, then it's not a dupe and either won't be closed or will be re-opened by an expert. I agree with everything in this answer. In fact, practicality aside, I don't even think providing an endless sea of answers for all C++ language standards is a good idea. That makes the question too broad and too unwieldy.
    – Cody Gray Mod
    Commented Oct 31, 2017 at 10:56
  • Once the new question has good answers, it may even be feasible to close the outdated question as a duplicate of the new question, in particular if the old question is not limited to a specific language version. E.g. “How do I forward arguments to another function in C++?” might be a duplicate of “How do I forward arguments to another function in C++11 or later?”, but “How do I forward function arguments in C++98?” is a legitimate non-duplicate question.
    – amon
    Commented Oct 31, 2017 at 11:15
  • @ivan_pozdeev Maybe because there are perverse incentives that keep getting in the way?
    – Braiam
    Commented Oct 31, 2017 at 11:56
  • @alain because there's one thing that SE as whole isn't willing to touch. If something we learned about the whole Documentation thing, is that SE is too scared to do serious overhauls to the reputation incentives.
    – Braiam
    Commented Oct 31, 2017 at 11:57
  • @CodyS.Pumpkins "I don't even think providing an endless sea of answers for all C++ language standards is a good idea" It doesn't need to be nor will ever be. Do everything changes every time a language standard gets released? No, right? That's why it's called standard.
    – Braiam
    Commented Oct 31, 2017 at 11:59
  • What if we set more rep additon for new, better answers, if they are not accepted as answer, but receive more vote up? To add some motivation. We don't just encourage quick answers, but also good ones. If an answer is not the accepted ones but better, someone may miss it.
    – WesternGun
    Commented Nov 2, 2017 at 8:30
4

The metadata that accompanies posts is not just for show, you know.

When you see a quesiton/answer, you can also see

  • when it was initially written and when it was last edited
  • a c++<version> tag on it (if any).
    • If not, post dates and/or content (e.g. product versions) suggest what standard the question and answer most likely had in mind. It's also fine to add the version tag post factum if you know what you're doing (≈can justify it convincingly in the edit summary).

Finally, if you have a reason to believe that an answer is obsolete, you can ask another question -- it's generally fine to do so if your situation is different enough for the old post to not apply to you. But in order for it to not be closed as a duplicate, you must1 provide the information that shows how it is not:

  • a reference to the old question, signifying that you saw and examined it and are not just too lazy to type a phrase into a search engine
  • the evidence that makes you believe it no longer applies
  • tag your question accordingly

So, I agree with @alain that the problem doesn't exist.


1Well, no one forces you to, of course, but since reviewers are busy people (and tend to be overzealous in rooting out the content that formally fits the stock close reasons), they likely won't waste their time examining your post too closely and will just close it as a dupe if you don't put reasonable effort into showing this prominently. And just to remind you, closing and reopening is a long and unreliable process...

1
  • 4
    That's not how I meant it; I think the problem does exist. I tried to say the problem is not as easy as it might seem (The "obvious answer" does not always work in my opinion).
    – alain
    Commented Oct 31, 2017 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .