29

I have a question which I would like to know the answer for in both C# and Java. I was told I needed to specify a language for the particular question. Does that mean I need to post 2 identical questions with a different programming language tag? (Implicitly convert double to int)

3
  • 1
    Don't mind the downvote on the linked question. Someone just got their downvote powers :)
    – Evorlor
    Oct 6, 2014 at 3:04
  • 1
    Most likely downvote was for not specifying language at all. Your post got attention mainly because you've posted on weekend, otherwise without language tags you'd get no views... Oct 6, 2014 at 16:09
  • 28
    Personally, I think you should be asking one question first, then using your new found knowledge to research and/or attempt the problem yourself in the other language. You will then be able to include your effort in your second question if you are still stuck.
    – Sayse
    Oct 7, 2014 at 6:53

2 Answers 2

23

Languages often behave differently, so it would be a good idea to ask the question in a different language if you want to get the answer for a specific question.

In this particular case, I believe that the behavior is the same (or at least that's what I've found in my quick testing), but don't let that stop you from asking (and perhaps self-answering now that you know) for future internet-dwellers.

What you don't want to do is this:

  1. Edit existing question
  2. Copy Markdown source
  3. Click "Ask Question"
  4. Paste Markdown source
  5. Replace references to C# with Java
  6. Change tags from C# to Java

While not technically a duplicate, you're just asking for someone to mark it as one if you're copy and pasting the source of the question.

Try changing the wording a bit and make it clear that you're looking for the Java behavior (and perhaps link to the original C# question and explain why you're asking a "second time" to preempt any close-voters).

4
  • 6
    I'd generally say, tagging a question as both languages is reasonable in this scenario - after all, you're effectively trying to compare language implementations.
    – Sobrique
    Oct 6, 2014 at 17:07
  • 4
    @Sobrique: I see it the same way. But, unfortunately, if one member provides a solution for one language and another member for the other, then you can only accept one of both answers.
    – honk
    Oct 8, 2014 at 17:24
  • 2
    @honk But you can upvote them both. And so can everyone else. Accepted answers are (often) overrated.
    – Air
    Oct 8, 2014 at 20:19
  • @AirThomas: I nearly expected this argument :) You are right, but an accepted answer is some kind of extra reward and as far as I am concerned, it gives me a good feeling when my answer is accepted ;)
    – honk
    Oct 8, 2014 at 20:38
4

Split into multiple languages.

Questions like that (C-like syntax languages) could apply to N languages: if we allow any combination of languages per question, we could have either:

  • one question with N answers (since no one knows all N languages). This means that it would be hard to find the language that interests new readers.

  • N*(N-1)/2 pairs of non-duplicate questions such that each question is contained in the sum of several other pairs of questions (AB is contained in AC + BC)

If it helps you though, feel free to mention what you already know from other analogous languages: just make it clear which language the question is about.

Things get murkier if:

  • the question is of a comparison between two specific languages... but generally such comparisons would also apply to N languages and we would have the same issues as mentioned above.

  • the question about general language design principles and would apply to any language... but generally such questions are too broad to be answerable.

So in general choosing one language produces the best questions and answers.

3
  • 2
    This specific question is pretty language-agnostic, the principles are the same across various languages and runtimes. People are helped more by a broader explanation that explains it for all languages than a language-specific Q&A that basically repeats the same for every language.
    – CodeCaster
    Oct 7, 2014 at 8:03
  • 2
    @CodeCaster Few problems are so simple that the Java and C# and C++ and C implementations will have 1:1 and onto maps. Examine rosetta code: different languages massively encourage different coding styles. Even though Java and C# are closer than most languages, this holds. Oct 8, 2014 at 20:09
  • @Yakk all I'm saying is that this question can be made more interesting by asking about the principle of storing integral and floating point data types, beyond a particular language, but of course for languages/runtimes sharing a common implementation. You can then reference all future questions about the principle to that common question, allowing for derivative questions when necessary.
    – CodeCaster
    Oct 8, 2014 at 20:29

You must log in to answer this question.

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