29

I have seen a lot of questions in the 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 and , but this question: 2D array initialization in Objective-C only has and does not have . What is the appropriate tagging for questions asking for code translation?

10
  • 45
    The appropriate tag for most of these questions is [please-close-me]. Commented Jul 16, 2014 at 13:30
  • 3
    @FrédéricHamidi I have seen some good questions which can only be asked by referencing how its done in another language. Swift is a good example. Commented Jul 16, 2014 at 13:31
  • 4
    You may have encountered a hidden gem. In my experience, most of these questions are of the "please translate for me that code I don't understand" variety. Commented Jul 16, 2014 at 13:32
  • @FrédéricHamidi stackoverflow.com/questions/24005678/… has a fair amount of up votes. Commented Jul 16, 2014 at 13:36
  • 5
    That's not a "translate my code" question, it's a "what is the equivalent type" question. It's arguably more interesting. Commented Jul 16, 2014 at 13:37
  • @FrédéricHamidi Ok, I guess thats a better example. Now what are the appropriate tags? Are both ok, even though the question doesn't really ask for something in objective-c? Commented Jul 16, 2014 at 13:39
  • 2
    To me both tags are okay, 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. Commented Jul 16, 2014 at 13:41
  • @FrédéricHamidi Ok sounds good. What if there were an actual [please-close-me] tag for when flagging wasn't enough. Commented Jul 16, 2014 at 13:44
  • Nah, we stopped doing them ages ago. Before I joined, there were tags like [pleasegimmetehcodez], but they were removed because they were traumatizing the questioners or something. Commented Jul 16, 2014 at 13:45
  • 2
    @FrédéricHamidi since such questions should be closed anyway, it isn't useful to tag them, and it only serves to complain about the low quality of the question. While help vampirism should be called out, put-downs are counter-productive. Commented May 15, 2022 at 2:57

2 Answers 2

42

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.

4
  • 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
  • 13
    Personally 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".
    – Adriaan
    Commented 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
4

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:

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.

You must log in to answer this question.

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