I have seen a lot of questions in the objective-c tag which ask for the conversion of Objective-C code to Swift code. I was wondering if these questions belong there. For example there is this question: Objective-C to Swift Equivilant which has both objective-c and swift, but this question: 2D array initialization in Objective-C only has objective-c and does not have java. What is the appropriate tagging for questions asking for code translation?
2 Answers
Please vote to close code translation questions. People need to explain (using words) what they are trying to do. If they have a bit of code in another programming language that illustrates their point, that's fine, but it needs to be in addition to a written explanation of the problem.
A question with just code asking for translation to another programming language could be closed as either Needs details or clarity or Needs debugging details (in the "community-specific reason" section)
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a Minimal, Reproducible Example.
-
Unfortunately I can't vote to close, but I can flag and will do so. Seems like they already have been closed. Commented Jul 16, 2014 at 14:47
-
13Personally I'd go for "too broad", since it is not unclear what they're asking: they want a clear-cut code-translation. Nor is it "seeking debugging help", since the code is working. They just didn't do anything yet in the new language, so there's nothing yet which isn't working. Translating the code probably has lots of possible solutions, each with pros and cons, therefore I'd go for "too broad".– AdriaanCommented Nov 7, 2015 at 11:20
-
Stack Overflow has many useful questions and answers about automated translators for programming languages. Are any of these questions acceptable for Stack Overflow? Commented Sep 10, 2016 at 13:56
-
2@AndersonGreen Good question. A lot of those are tool recommendation questions, so they should be closed as off-topic for that reason. If someone has a question about writing a code translation tool, or a specific question about using one they've already selected, that would be on-topic for Stack Overflow. (Note that those are all different cases than the examples in this meta question, which were just people asking us to translate some code for them.) Commented Sep 10, 2016 at 14:01
If the question is on-topic as laid out in Bill's excellent answer, the "other programming language" shouldn't be tagged because the question isn't about it, it's just for illustration. As explained in the tag help page, "Tags are a means of connecting experts with questions they will be able to answer", so for example, if you ask a Java expert how to translate something into Swift, they might not even know Swift.
Some examples:
- What is the bash equivalent to Python's `if __name__ == '__main__'`? is about Bash with reference to a Python feature and has bash but not python.
- How do I create variable variables? is about Python with reference to a PHP feature and has python but not php.
- Python-like C++ decorators is about C++ with reference to Python, so I removed python just now.
Also note that multiple language tags can mess up syntax highlighting. With SO's setup of HLJS, it falls back to automatic detection, which is often wrong. For example in Python-like C++ decorators, before I fixed the tags, some code blocks were highlighted as C# or JS, including in the answers.
[please-close-me]
.id
is an Objective-C type so clearly[objective-c]
is in the picture. The questioner is looking for an equivalent in Swift, so[swift]
is legit too.[pleasegimmetehcodez]
, but they were removed because they were traumatizing the questioners or something.