What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

Today I came across this post, where all the variable names were in Slovak. Obviously, when the variables are named in Slovak, it's difficult to figure out what the logic is.

Before posting this question, I found this post that mostly answers my question; except the question itself was in English, just the variable names were not. This post doesn't answer my question either, because if you remove the non-English content, there's no more code.

In this particular case, I translated the variable names to English, which may also have been the wrong move, but I wanted to know what to do for future reference.

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

I wouldn't touch them.

From a technical perspective, this would result in equivalent code at best. At worst, it could cause accidental changes in meaning and/or behavior.

From a reader understanding perspective, this could make the OP's intent somewhat more clear, assuming that the OP selected sensible variable names in his native language in the first place. However, it could just as easily reduce the usefulness of existing comments/answers that refer to the old names.

Changes also run the risk of confusing the OP, who might not understand the English names. Heck, I get thrown for a loop sometimes when my variable names are changed from English to English, and my English skills are quite good (in my not-at-all-humble opinion).

You could achieve all of the pros with none of the cons by posting a list of translations in a comment, or maybe in the question body underneath the code snippet.

share|improve this answer
    
+1 for adding a key of translations. –  Servy Dec 5 '12 at 19:53
    
Yeah, that's what I should have done. I didn't think of it. Thanks @PopularDemand –  durron597 Dec 5 '12 at 20:02
    
Generally in programming, variables names mean nothing. A good programmer should be able to tell what's happening without knowing what the variable "translates" to, especially in the example provided. So, from that perspective alone, I see no reason to edit the variable names. –  animuson Dec 5 '12 at 20:19
    
@animuson I usually can tell, but it takes more effort - I have to figure out what something's for, not just immediately knowing. The question is much less useful if people have to figure out what variables mean before they can understand the post. –  durron597 Dec 5 '12 at 20:22
    
@animuson I think that applies much more in the professional world than on Stack Overflow. When you're looking at a small, possibly non-compiling piece of a program on a question that provides only minimal or incomplete context, good names can be pretty helpful. –  Pops Dec 5 '12 at 20:27
    
@animuson wrote "A good programmer should be able to tell what's happening without knowing what the variable 'translates' to." Maybe, if the code isn't too sophisticated, but most importantly, only if the code works. This is less of an issue for code that makes heavy use of a common API, but a broken algorithm in a foreign language is incomprehensible. –  arx Mar 3 '13 at 14:23
    
@animuson "Generally in programming, variables names mean nothing." I strongly and totally disagree. If your statement were true, you could code with variables names like "a, b, c, d, e". And from there, let's name your functions f1, f2, f3, f4 (and so on, on classes, files...). The difference between a sensible, explicit and non ambiguous name and one chosen with less care is often one or more bugs added at first write, or on further edits or even refactors. –  Guillaume Jul 30 '13 at 21:56
add comment

I think that's ok, but there are a few caveats:

  • Make really sure you're not introducing bugs with the renames.
  • Make really sure you're not fixing bugs with the renames.
  • Check the answers – they are going to look real strange if they reference the original names that the question doesn't contain anymore.

So you better be fluent in both the natural and programming languages of the question.

If you don't have full edit privileges, I'd say avoid it unless it is completely trivial - these things are hard to check unless the code snippet is really trivial (and if it is, it probably doesn't need fixing anyway).

share|improve this answer
    
I do have over 2000 reputation on SO. Interestingly, there was one answer that was using the old variable names, but it was written while I was making the change and has since been deleted. –  durron597 Dec 5 '12 at 19:33
5  
There's one other major thing you have to consider here: by doing so, you may be forcing the OP to translate them back in order to implement any solution into their program, especially if it was only a snippet out of a larger program. –  animuson Dec 5 '12 at 19:45
1  
I think value to future visitors (including potential answers) trumps that. OP will hopefully get his problem fixed - and extra translation back to his own language shouldn't be too bad. –  Mat Dec 5 '12 at 19:49
    
@animuson Thankfully most IDE's have a refactor mechanism that makes that easy(er), and they still have their original code to compare with their edited OP to see what translates to what. –  Servy Dec 5 '12 at 19:54
    
@animuson But no sane programmer uses non-English variable names in production code, alrite? –  H2CO3 Aug 7 '13 at 15:08
add comment

You must log in to answer this question.

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