15

I think that the tag could need a clean up.

The current tag wiki excerpt reads:

For questions regarding the translation of code from one programming language to another. NOTE that asking to have your code translated is not suitable for Stack Overflow.

At first this looks like the two sentences contradict each other. I think this could use a rewording.

In my opinion we can group questions into three categories

  1. Questions talking about the conversion of a simple functionality of language A to language B are on-topic.
  2. Questions asking to convert a whole program from one language to another are off-topic.
  3. Questions asking about a converter to translate a program from one language to another are also off-topic

There is a fine line between 1 and 2. When do we talk about a simple functionality (1) and when about a whole program (2)?

Questions falling into the first category are fine and can be left as they are. For the second category I suggest the following steps:

  1. Remove the tag
  2. Close the question as: Needs more focus.
  3. If the question can be deleted by the roomba (i.e. it has a negative score and no answer), leave it closed. If not vote, to delete.

For the third category the steps are the same as with 2), but the question should be closed with the: Seeking recommendations for books, tools, software libraries, and more reason.

For the record: there are currently 374 questions in total, a subset of 46 have a negative score, and of those 14 are already closed.

7
  • 8
    Why do we need this tag at all? Considering the first category, which is on-topic, does the translation part even relevant? Why not instead of asking "In language A I can do x. How do I do it in language B?", just ask "How do I do x in language B?" and the whole translation thing disappears...
    – Tomerikoo
    Commented Jun 1, 2021 at 12:44
  • @Tomerikoo There may be subtle differences in the way two languages implement similar functionality. For instance, replace in JavaScript replaces the first instance of a match on the first argument with the second. Other languages replace all instances. A question asking how to replace strings in one of these other languages might miss out on JavaScript's fun interpretation, leading to bugs as the OP blithely thinks they are the same. Now, that could be considered the OP's fault for not reading TFM, but... Commented Jun 1, 2021 at 12:59
  • @Tomerikoo "Why do we need this tag at all?" because we need a tag for all and every possible characteristic a question has. Don't you know that an expert on sql don't know that the sql replace() function replaces all instances and that if they want to translate a javascript question, they will be blown away by the difference. Now in more seriousness, that last thing is a non-issue since you have to describe what the source language does anyways.
    – Braiam
    Commented Jun 1, 2021 at 13:15
  • @HereticMonkey I still don't see how the translation part is important here. Either you ask "How do I replace all instances of a substring in language B", or "How do I replace the first instance of a substring in language B". Your language A shouldn't matter at all if you describe what you want to do, as Braiam said at the end of his comment
    – Tomerikoo
    Commented Jun 1, 2021 at 15:08
  • @Tomerikoo But do you see how you changed the question because of the original language? What if you're not aware that's the behavior of JavaScript's replace function? That's why a translation part is important, because an expert in the original language will know the nuances of those gotchas, whereas an expert in the new language may not. Leaving out the translation places a larger burden on the OP to do the research and understand the original language. I haven't seen that kind of research in a question in long time. Commented Jun 1, 2021 at 15:21
  • @Braiam "you have to describe what the source language does anyways". Since when? Commented Jun 1, 2021 at 15:26
  • 1
    @HereticMonkey since we implemented some sort of quality standard...?
    – Braiam
    Commented Jun 1, 2021 at 16:06

2 Answers 2

13

I think we can all agree that out-right translation questions are blatantly off-topic and easily closed as Needs More Focus. Such questions like:

I have this code in Python:

[42 lines of code]

How can I write it in C?

As you said:

When do we talk about a simple functionality (1) and when about a whole program (2)?

Let's start narrowing it down:

I have this loop in Python:

for i in range(10):
    mylist.append(i * 2)

How can I write it in C?

Now that's only 2 lines of code - pretty scoped right? But as a translation question, it is still not focused. What is the exact blockage the OP is having? How to write the loop? How to add elements to a list? How to multiply? Each of those questions could be posted by itself.

So let's do that:

I have this loop in Python:

for i in range(10):

How can I write it in C?

Now we have a perfectly scoped question - no doubt about it. My point is: the fact that you have a code in Python is not interesting and doesn't add any value. Your question is: "How do I write a loop going from 0 to N-1 in C?".

There are exceptions though, most notably how to implement a built-in notion of one language in another, which doesn't have it built-in (and is not so straight-forward like a simple loop). In this case, a code-sample in another language demonstrating the concept might help. But still, such questions don't need the code-translation tag (and not even the other language's)! This is not really a translation question, but a how-to question with a concrete example from another language.

If it wasn't clear by now, my honest opinion is that we do not need code translation questions and therefore do not need such tag as well. The existence of this tag only promotes the off-topic questions we do not want it to have.

We might as well burn...


Similar discussions, mostly supporting that strict code-translation is off-topic:

7

I'd always assumed the purpose of tags like that was doing the translation programmatically. A bit like , but translating to a similar level on the high/low level scale, like f2c (Fortran to C), not like C or Fortran to asm. That's what's left after ruling out questions about translating any specific piece of code.

For example, like

Topics related to the generation of code as the output of an application, instead of directly writing code by a programmer.

It's not about generating code by hand with a keyboard, it's about writing programs which generate code. Another possible way for the tag to make sense could be for general techniques, similar to the tag which has usage guidance:

Debugging is a methodical process of finding and fixing bugs in a computer program. IMPORTANT NOTE: This tag is ONLY for questions about debugging techniques or the process of debugging itself, NOT for requesting help debugging your code.


Another example could be a program that turns some specific kind of perl program into a Python program, using some limited subset of perl's functionality so it's not a full-blown compiler or perl interpreter.

Or perhaps more likely, for languages that are closer to compatible, Objective C to C, or C++ to C, as a way to get library bindings / wrappers.

I'm not sure we need a tag for that; I'd guess that the details of every case would be specific enough that it's not something where you'd be likely to want to look at other question, unless maybe the source and target languages were the same.


Alternatively, the intent of that sentence was to remind people that the existence of this tag isn't a loophole to justify questions like "here's my code in X, write it for me in Y".

But that the original author of the tag-usage guidance wan't intending to rule out "here's my working code in X, I have it almost working in language Y but it's having specific-problem Z / with certain inputs / whatever".

If that's the only way it gets used, agreed we don't need a tag for that either. Just tag the desired language, and maybe also the original language if there's anything non-obvious about how the original works.

You must log in to answer this question.

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