4

Each day I browse SO, there's a fair share of questions asking for a magnificent wonder of code conversion - from Java to JavaScript, from Perl to PHP, from SQL to Haskell etc.

Usually it means the OP got some legacy application and was asked (as politely as possible, of course) by their bosses to rewrite it into something more shiny/less crappy ASAPOES.

In extreme cases, some 100+ LOC monster is pasted directly into the question, making it as unhelpful for anyone but the OP as possible. That's rare, but that's really annoying, have to admit.

The problem is, I don't know how to deal with these questions correctly. The most natural reason for closing them was 'too localized', because they usually (but not always!) are. But that reason is gone from the list now.

There's, of course, 'minimal understanding of problem' check - but, frankly speaking, I don't think this reason will give a really good explanation of what's wrong with those questions. I'd rather see something more direct, but fail to come to any good AND concise line explaining what's really wrong with that 'conversion' approach. Are there any good ideas about it?

P.S. Also, there's another type of 'conversion' questions - when someone shows an idiom/pattern taken from one language, and asks about how better to express the same ideas in another language of choice. While these are on the edge on being too subjective, I suppose, this particular question is not about them - it's mostly about 'gimmethecodez' ones.

UPDATE: Ah, now I see this question among the links, which is basically about the same problem. Ironically, it has 'too localized' option choice as an accepted answer.

UPDATE 2: Reopening the question, as the 'minimum understanding' reason has gone away (here's the announce), and I'm really not sure about how the remaining ones fit in this case.

3
  • I think "minimal understanding" is the closest reason we can use here for question asks for conversion with a wall of code. As for the idiom/pattern, close/leave open will depend on the question.
    – nhahtdh
    Sep 8, 2013 at 15:20
  • Yeah, those were a perfect fit for "too localized", but that close reason was misused too often, so got nixed.
    – Oded
    Sep 8, 2013 at 15:26
  • 1
    I think the fundamental question here is if Stackoverflow wants to be a site where you can do the work of others for reputation. There might be cases where such a 1:1 translation could be helpful to someone learning a new language.
    – user248333
    Jan 17, 2014 at 21:47

2 Answers 2

2

Too broad

Converting code from language A to language B requires a minimum of two steps:

  1. Understand what the provided code in language A does.
  2. Implement the derived specification in language B.

The two steps call for different expertise — language A and language B. These two steps should be asked about separately. In many cases the piece of code that is given is too long and questions should be focused on specific parts of that code.

Close as too broad and tell the asker to split their question into one or more understanding question, and one or more implementation question. Tailor your comment to how far each half of the question would be from a reasonable question.

Unclear what you're asking

In many cases, it appears that the asker knows what the code in language A is doing, but isn't familiar with language B. In such cases, the question is in fact about language B. So it needs to be worded in terms that people who know language B understand. The problem statement needs to be described in English, not in language A.

Close as unclear what you're asking, since the question is not worded in a way that the target audience can understand. Write a comment requesting that the asker explains in words what the existing code is doing and thus describe their requirements in a comprehensible form.


We do the same thing on other sites. For example, when someone asks for the Linux equivalent of a Windows program on Unix & Linux, we request that the asker specify what feature he wants — both because we're not experts in what Windows programs do, and because programs typically have more than one feature. If the requirements are only expressed in terms of a Windows program, that makes the question unclear on U&L. If a specific feature is not identified, that makes the question too broad.

Language sites tend to have a custom off-topic close reason for similar cases. For example, if someone asks for a translation of a German phrase on French Language, we'll close it and request an explanation of the phrase in French or English. In this case, we close as off-topic, because understand the German phrase is off-topic on a site about French (this is different for programming language conversion, where the expertise to understand language A and to write language B are both found on Stack Overflow).

13

The problem is, I don't know how to deal with these questions correctly.

They are off-topic. The specific off-topic reason would be:

Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results.

OP needs to understand both languages and try to solve their own problem first.


Now the yard stick on these is - how helpful will an answer be to others viewing the question. Normally it will not be. As such, these should be closed and deleted. The exact close reason is not as important as much as the need to close and delete.

You can always add a comment to that effect.

8
  • "This question appears to be off-topic because it is too localized." as custom close reason. Why not? Oct 26, 2013 at 23:31
  • @JohannesKuhn - We had that. And it was misused. A lot. The biggest issue is what does "too localized" mean? It is too open to interpretation and abuse.
    – Oded
    Oct 27, 2013 at 7:30
  • It is too specific that it is unlikly to help anyone else. "Convert code from A to B" - check. "Code Review" - check. "Find my typo" - check. Oct 28, 2013 at 8:51
  • @JohannesKuhn - sure. This one fits. But there were many others that didn't fit that were closed with it. That was the problem.
    – Oded
    Oct 28, 2013 at 9:00
  • I need a cheat sheet how I should close this 3 types now. "Convert code from A to B" - "demonstrate minimal understanding". "Code Review" - ? "Find my typo" - ? Oct 28, 2013 at 9:16
  • @JohannesKuhn - Convert code and Find my typo are both minimal understanding (need to understand the languages involved and compiler output, respectively). Code review - possibly "too broad", as there can be an infinite number correct of answers.
    – Oded
    Oct 28, 2013 at 9:24
  • Thanks. I'm going to miss TL much less. Oct 28, 2013 at 9:25
  • And now? I miss both TL and minimal understanding. Aug 27, 2014 at 9:45

You must log in to answer this question.

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