What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 122 Stack Exchange communities.

A lot of SO users, especially novice or inexperienced programmers who frequently ask questions, are genuinely confused about the differences between C and C++. As such, you frequently find questions that are posted with code that is specific (or should be specific) to one language or the other, but are tagged with both the C and C++ tags.

Now granted, the languages are not entirely dissimilar. C++ is even designed to be [mostly] backwards-compatible with C. But if you're writing C code in C++ and taking advantage of that backwards compatibility, then you're not really writing C++ code. And your question should be tagged accordingly.

This issue extends beyond the simplistic difference that "C++ is an object-oriented language". C is not a subset of C++, and C++ isn't simply "C with classes". That language doesn't exist. One simply does things differently in C++ than they would in C, and vice versa. If the tags don't take that into account, it becomes an unfortunate reality that many of the answers don't take that into account. One might argue that the actual differences between the two languages are somewhat "rare" in common usage, but a site like Stack Overflow is going to attract a lot of questions that are specifically about those weird, edge cases that a developer couldn't figure out on her own.

Most importantly, for questions and answers that involve (or quickly can evolve to) "best practices", the recommendations that one would make for C are almost always different from the recommendations for C++. Despite the two languages' syntactical commonalities, the idioms are in many cases so different as to be polar opposites. If syntax were the only concern, tagging questions C and C++ would make as much sense as the duo C++ and C#. But I bet there aren't very many questions with those two tags together (aside from those concerning interop, which obviously don't count...)

From my observation, the worst possible thing is that questions about one language or the other get hastily closed as duplicates of questions that are specifically about the other language. The issue is that the other question carries both tags, so it's natural to assume that it either covers both languages or is about one of those things that remains the same. I've even voted to do this myself and failed to notice the error until someone more careful than I posted a comment highlighting the difference. It's difficult to imagine how many times 5 people have hastily agreed to close a question before noticing the duplicate is actually about the other language, despite carrying both tags and superficially appearing to be a dup. And if C/C++ programmers can make that mistake, imagine how easy it is for smart programmers in other languages to make it.

Therefore, it seems that we should strongly consider disallowing a question from being tagged with both the C and C++ tags simultaneously. The relatively small and specific questions for which this would make sense would not be substantially negatively affected by having to choose one tag or the other. This wouldn't have to go into effect for past questions if that keeps down the amount of work required to implement it. The primary concern, it seems to me, is new questions. At a minimum, we should consider showing a warning to the asker when they add both C and C++ tags to a question.

To pre-empt comments that the community could always edit the tags to fix erroneous co-tagging, consider that it's not always obvious from the question which language the asker is hoping to discuss. That forces editors to make a lot of assumptions about the question being asked that may or may not be correct. It seems the goal of editing (even tags) should be to minimize the assumptions necessary, not increase them. If the asker is forced to choose the most appropriate tag, she may choose incorrectly, but it seems the chance is greatly reduced. If and when it becomes obvious that someone has chosen incorrectly, an edit easily solves the problem.

share|improve this question
Should similar tags (like discussion and feature-request on meta) also be mutually exclusive? –  dalle Jan 10 '11 at 21:52
Hypocrite: You favor banning dual-tagged questions, but used "C/C++" in your question. –  Ben Voigt Apr 7 '11 at 3:52
@Ben: The implication wasn't that they're the same language. I'm lumping them together for the specific purposes of this question. I think that's clear from the context. "C/C++" modifies programmers, not the language itself. It would be no different than saying "C#/Fortran programmers". –  Cody Gray Apr 7 '11 at 6:38
I think you missed my point. It's absolutely correct to use "C/C++" in that way. But you provided your own counter-example to a post suggesting "decide whether you're talking about C or C++, it can't possibly be both", because clearly "C/C++" IS both. –  Ben Voigt Apr 7 '11 at 14:05
add comment

3 Answers

up vote 13 down vote accepted

A warning might be useful. Forbidding dual tagging, definitely not.

Consider: "How do I write a header file so that it can be #included by both C and C++ programs?"

Furthermore, I've seen people retagging questions from c++ to c because they feel no C++-specific features are being used, even when the code invokes different behavior on C vs C++ compilers. Classic example: "Error on line int* pi = malloc(sizeof (int));". This is a perfectly reasonable issue under C++, and retagging c destroys the meaning.

share|improve this answer
+1, Good example! –  Gabe Apr 7 '11 at 6:05
Agreed. Further reflection indicates that my proposal definitely went too far. I hadn't revisited the question again until being notified of your answer. I agree that a warning is definitely the better solution. And once such a warning system is implemented, it could be extensible for other potentially "unsavory" tag combinations (if the need were to later arise). –  Cody Gray Apr 7 '11 at 6:39
Note that I also wasn't proposing that others retag the question to C. I think that's almost always a mistake. That's why I was searching a way for the original asker to pick the most appropriate tag. –  Cody Gray Apr 7 '11 at 6:40
@Cody: Then exactly what did you mean by "But if you're writing C code in C++ and taking advantage of that backwards compatibility, then you're not really writing C++ code. And your question should be tagged accordingly."? Cause it sounds like you're saying such questions should be tagged c, and I'm telling you, if you using a C++ compiler, the question should be tagged c++, regardless of which functions and classes from the standard library are being used or not used. –  Ben Voigt Apr 7 '11 at 14:03
Ah, that's a fair point. Hrmm, it's been a while since I wrote the question. I apparently forgot some of the arguments I made... –  Cody Gray Apr 7 '11 at 14:05
add comment

This seems like a really specific use-case; the engine really needs special functionality added just to detect people using and on the same question? If the poster really doesn't know what they're doing, this won't fix anything; they'll add both tags to their question, see the error message (if it's a warning I guarantee it won't even slow them down, take a look at the "this post is subjective and will likely be closed" warning), and delete whichever tag they typed last, so now instead of a bunch of posts with both tags that are easy to find, there will be a bunch with one tag that should have the other

share|improve this answer
It's definitely a specific use case, but that seems like something that afflicts tagging in general. You're probably right about people ignoring warnings, though. My concern isn't that the doubly-tagged questions are difficult to find, it's that they're confusing to everyone and perpetuate the misunderstanding that the languages are the same. –  Cody Gray Jan 10 '11 at 15:30
It would be nice if tags could be marked mutually exclusive with specific other tags. I could probably come up with a few others, too, particularly ones related to specific versions of software. –  Powerlord Jan 10 '11 at 18:06
add comment

This wouldn't solve anything.

There are lots of questions that were originally tagged [c] where the OP was clearly using [c++] and there are lots of questions that were originally tagged [c++] and when a C++ solution was given, the OP said "oh, no, I'm using C."

Forbidding a question from being tagged both [c] and [c++] is just silly. There are plenty of questions that can be asked about both languages (for what it's worth, one of my questions is correctly tagged both [c] and [c++]).

share|improve this answer
Well... maybe encourage people who don't know any better to tag them with both. That way an expert who understands the question can come along and retag them. –  uɐɯsO uɐɥʇɐN Jan 10 '11 at 17:44
This answer is incomplete (and as a consequence, overly negative), because it doesn't address the proposed alternative in the question, which is "At a minimum, we should consider showing a warning to the asker when they add both C and C++ tags to a question" I agree with your reasons for not forbidding dual tagging, but I think a warning would address a lot of cases (and they appear to be very frequent) where the questioner uses both tags due to inexperience rather than legitimate need (albeit Michael's answer does state some concerns with having a warning). –  JBentley May 7 '13 at 22:11
add comment

You must log in to answer this question.

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