13
\$\begingroup\$

I frequently come across questions from new users that are tagged just with , whereas it is very likely that by now (end of 2014) their compilers are C++11 compliant.

In such cases, should we refrain from suggesting the use of new features, even if those would improve the quality of the code? The ideal scenario, I believe, would be to post a comment in the OP asking for clarification and the addition of , if that is the case. However, the feedback cycle might take some time. Time that could be better used writing an answer instead.

\$\endgroup\$
7
\$\begingroup\$

My feeling on this is that we are not answering the question just for the OP but also for everyone that comes after. So we should be answering the question based on the best methods for the current version of the language.

If the question is tagged C++ then I will provide insights that use all current features up to and an including C++14 (C++17 is not standardized enough to use as a reference yet). Though it is probably worth mentioning that it is a C++11/C++14 feature.

Tag:

C++   =>   Provide the best review you can for the current version on the standard.
           Which is C++14.
           But it is still worth mentioning C++11/C++14 specific feature (and alternatives)
           Though soon we should stop mentioning C++11 specific features.

C++98/C++03/C++11/C++14/C++17
      =>   Provide answers specific to that version of the language.

It is professionals with an older code base that are usually locked to an older version of the standard. These are not the people asking questions here. So I am really not to worried about providing the latest information. If they are locked to a specific version of the language they should explicitly say so by tagging it with the correct version.

Note: all the standard modern compilers now support C++14 (maybe you have to throw a flag). So students especially have access to all the new features (since they are all free as well). Since this is the majority of the people that ask questions we should make sure that we answer with correct up to date information.

\$\endgroup\$
  • \$\begingroup\$ Yep, that's roughly my line of thought. c++ is the most generic tag, so it should mean the most up-to-date practices and standards of the language. \$\endgroup\$ – glampert Nov 24 '14 at 1:10
  • \$\begingroup\$ But my answer still has the least votes. I think on meta you should be looking for the highest consensus not the opinion that matches yours (though I do appreciate the vote of confidence). \$\endgroup\$ – Martin York Nov 24 '14 at 3:22
  • \$\begingroup\$ I also think your arguments are objective, it's not just because of the similar opinion. This answer deserved more visibility, that's why I changed the accepted vote ;) \$\endgroup\$ – glampert Nov 24 '14 at 5:08
  • \$\begingroup\$ ... And your answer has low votes because it was a late answer so, lets wait and see. \$\endgroup\$ – glampert Nov 24 '14 at 5:09
13
\$\begingroup\$

Unless stated otherwise, I don't see the harm in mentioning C++11 anyway. I personally assume that the OP doesn't have access to C++11, unless either the tag is present or I see some existing C++11 features being used. For homework, I just assume no C++11, though I could still add some in case the student (or someone else) may find it useful someday.

You're free to add the tag yourself if you see that the OP is using C++11. If, however, it's stated that C++11 is specifically discouraged (perhaps a special implementation), then it may be okay to add the tag instead. So, even if you see neither of these tags, you may still post a C++11 answer.

\$\endgroup\$
  • \$\begingroup\$ Why would you assume people do not have access to C++11 or even C++14. The majority of people asking questions here are students. They will be the ones that download the free compilers (g++/clang/visual studio express). These all support the latest versions of the standard. \$\endgroup\$ – Martin York Nov 23 '14 at 18:55
  • 1
    \$\begingroup\$ @LokiAstari: I guess that's because they're still not taught C++11 and above, thus it doesn't show up in their code. I can certainly say the same about myself. \$\endgroup\$ – Jamal Nov 23 '14 at 19:26
11
\$\begingroup\$

Assume is the opposite of safe.

Either of this will do (some may need a feedback cycle, some won't):

  • Ask for clarification
  • Answer stating where C++11 can improve the code
  • Answer for both
  • Answer stating that something will only work in C++11
\$\endgroup\$
  • 2
    \$\begingroup\$ Actually, the opposite of safe is unsafe. :p \$\endgroup\$ – IEatBagels Nov 18 '14 at 18:37
  • \$\begingroup\$ @TopinFrassi assume = unsafe :p \$\endgroup\$ – Bart Calixto Nov 18 '14 at 22:01
  • 3
    \$\begingroup\$ @Bart Well now it is. Did you mean assume == unsafe? :p \$\endgroup\$ – nwp Nov 19 '14 at 8:57
6
\$\begingroup\$

I would say it is not safe to assume for , for a few reasons:

  1. Not everyone has the luxury of working on new projects with C++11 - there might constraints that prevent them from utilizing C++11, whether its integration with an older codebase, or the tools used in their enterprise, or simply excessive bureaucracy or adherence to previously set code guidelines that are out of their control.
  2. Students or programmers who do not have access to newer C++11 capable tools or books.
  3. Programmers who have a strong dislike of C++11 due to many years of coding in say, C++98. Granted, this should never be a reason, as developers should evolve with the language, but we cannot control that.

While it's possible to glean from the code whether the programmer is using C++11 in much the same way that PHP questions are not categorized by , , , etc tags, I'm still strongly against defaulting to for the tag.

\$\endgroup\$
  • 2
    \$\begingroup\$ For 1) I'd argue they should mention any and all constraints in the question, 2) is a fair point, but code review is also about education, and they should know these features exist, 3) is a weak point. I won't stop admonishing C# users for not using the PascalCase because their preferences are out-dated. \$\endgroup\$ – Nick Udell Nov 18 '14 at 10:18
  • \$\begingroup\$ @NickUdell Wholly agree on point 3 (and as stated in answer, it should never be a reason). As to your rebuttals to points 1 and 2, they are both valid arguments. \$\endgroup\$ – jsanc623 Nov 18 '14 at 15:47
  • \$\begingroup\$ This does not really answer the question. We basically all agree that the assumption C++ == C++11 is broken. The real question is: If I review c++ code, should I use C++11 or not? \$\endgroup\$ – nwp Nov 19 '14 at 9:03
  • 2
    \$\begingroup\$ C++11 programming is fundamentally different from pre-11 C++ programming. Dangling cute new features in front of pundit's nose can get them interested in C++11 but I think there is more value in formulating answers with straight and clean 'traditional' C++. For many askers even the STL (and other advanced template usage) will be daunting enough. \$\endgroup\$ – DarthGizka Nov 19 '14 at 15:02
  • \$\begingroup\$ @nwp to answer your question, if you review c++ code, I personally feel that you should not use c++11 unless the asker has identified the code as c++11 OR the code is very obviously c++11. \$\endgroup\$ – jsanc623 Nov 19 '14 at 16:21
  • \$\begingroup\$ Students are more likely to have c++11/c++14 compliant compilers as they are not locked down by old code bases. \$\endgroup\$ – Martin York Nov 23 '14 at 18:41
  • \$\begingroup\$ People who have a strong dislike for new features. Can ask for a review with a specific version rather than assuming we will guess. \$\endgroup\$ – Martin York Nov 23 '14 at 18:57
  • \$\begingroup\$ I agree we should not default to C++11 since the current version of the standard is C++14. If you ask a question about the language we should provide the most modern upto date way of completing that task. If you want the code reviewed for a specific language then you should tag it as such. \$\endgroup\$ – Martin York Nov 23 '14 at 18:58
3
\$\begingroup\$

Yes. We've had C++11 for 3 years now. There may be programs in which it can't be used yet, either due to outdated tools or outdated management. But in those cases the programmers are aware of that problem, and can tag their questions accordingly. Thus, a question which is not tagged [C++03] can be assumed to be current [C++], i.e. [C++11]

The one exception is homework. For reasons I don't fully understand, many in the academic world are lagging (shouldn't it be the other way around?). Their students in particular may not be aware of C++11.

\$\endgroup\$
  • \$\begingroup\$ Well current is C++14 but I see what you mean. \$\endgroup\$ – Martin York Nov 23 '14 at 18:40

You must log in to answer this question.

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