I know it is rather strange question, but I've been toying with this idea for last couple of days, and I am thinking if it might be reasonable?
I come from C++ (and C), but I am sure every programming language has it's no-no-no(s) when it comes to code. And yet those no-no-no(s) are duplicated in perpetuity (by the nature of people copying the code from bad examples, or CS teachers being less than stellar). What really alarms me, is that mere postings of such code on SO supports this perpetuation - more bad code can be found.
To give examples, following is seen multiple times a day in C++ tag:
using namespace std;
or
#include <bits/stdc++.h>
or, in sockets
tag
bzero((char *)&serv_addr,sizeof(serv_addr));
All those examples are unequivocally bad, there is no dispute about them. There are SO duplicates to cover them. Yet they come back over and over again. On a lucky day there is a comment under the question, pointing out to those problems - but they do not seem to improve the sitatuion.
I have following suggestion. Would it be worth considering an automatic, tag-specific code verifier? Whenever a question is posted in a specific tag, and it contains well-known bad code, a popup will say that posted code is bad with link to a SO question explaining why it's bad? The question will not be accepted until bad code is fixed. I realize it is not that easy and general static code analyzer within SO is out of the question, but I suppose even if we cover easy cases (all above examples are covered by a single regexp, they are call copies from the same bad sources or copies of thereof) we could probably raise a bar a little bit?
using namespace std;
affects some sort of resolution ambiguity. Those are all valid questions. I think this is better left to comments.using namespace std;
. Furthermore, you'd need a topic expert on every tag to make such a judgement call. Also, I'm pretty sure such a block isn't going to do much. Everybody already finds ways to work-around filters anyway. And if people start using misspellednamespace
or inserting ZWSP's into the code, that's just gonna piss off the people reading them.#include <bits/stdc++.h>
orusing namespace std;
if it has no effect on the problem? We can comment to let them know it is a bad programming practice. I don't think we should require they be removed.