tags:

views:

1863

answers:

29

Duplicate

Should identifiers and comments be always in English or in the native language of the application and developers?

For people who are not native English speakers, which language do you use to declare variables, classes, etc. ?

I had to continue a project from a Spanish guy. Everything was written in Spanish.

Since this time, I have decided to use English identifiers ( variables, classes, file names) and write comments in french. Everything was in french before that.

What are the general recommendations about that practice?

Do you use English everywhere knowing that no English people will work on your project ?


Edit :

Here's a post from Jeff Atwood about this subject:

The Ugly American Programmer

+4  A: 

I use Latin for home projects. However, if anyone else will be reading, they're going to be stuck with English because that's the only other language I know (and it's a little more widespread). :-)

Brian Knoblauch
Are you kidding?
UpTheCreek
No joke. While not practical out in the real world, it's a very fun and elegant language.
Brian Knoblauch
It's only against such a twisted mutt as English that Latin could be considered "elegant". :-)
Ken
+2  A: 

Even though I can speak some french and some german , I think I will always write in english . It's kind of an universal language , and almost anyone can understand it a little.

Geo
+5  A: 

Most programming languages are fairly English-centric (the commands are going to be english-like). From that point of view wouldn't it make sense to write the rest of the code in English, to keep from needing to switch between languages?

tloach
+4  A: 

Sure you can, if you want to write unmaintainable code.

hmemcpy
best. page. ever.
LiraNuna
+34  A: 

I'm not a native English speaker, but everything I write in code is in English. Most (not to say all) of my colleagues are Dutch, like me, however, you never know who will be looking at your code a year from now. I think it's just good practice not to limit your code to people who speak the same language.

The thing is that when you get further south within Europe, the mastery of English tends to drop and people might still create unreadable code, even when they're trying to do it in English.

I guess the most important thing is that you yourself understand what you're writing, but when possible, do it in English.

Rik
I code in English, comment in English, but sometimes when nothing works and I'm really annoyed I might add some nice comments in Polish :)
Michał Piaskowski
Same here. French coding in english. That's how I do things, it's a requirement in my company, and you can't work with other big companies without it. It's far better to have a common language (for technical stuff, not literature) and it happens to be english this century, so let's write in english.
e-satis
@Michał: I do that too, but my native language is Swedish. :D
Spoike
I write in English, too, although my native language is Catalan. It's a business requirement. I'd even like to force that to be British English, for consistency.
Daniel Daranas
Yep, count me in - I code and comment in English too (though my native language is Slovene).
+2  A: 

Just English but as I have read through so many comments, in code, that have been written in French, Italian, Spanish, even Russian - I feel like I can READ those languages with great ease these days. If I hear them spoken, I can do a darn good job at understanding the speaker. But, ask me to speak those languages and I am not good at it.

Optimal Solutions
+8  A: 

I maintained one piece of code where the variable names were in German.
I only speak English.
Once I got off my duff and translated the names it was no big deal.

Plus I will forever know that suchen is German for searching :)

Dining Philanderer
Gut antwort !( Good answer )
Geo
That's "Gute Antwort!" for you!
ammoQ
+11  A: 

I am also not a native English speaker, but I write all my code and comments in English. It makes code more readable and frankly faster to parse. For example, the following construct can be read in English fast and you understand it without having to think about it:

while (!done) {
}

However, had I been using variables in German (also not my mother tongue) that would read:

while (!fertig) {
}

Now, reading this may subconciously confuse you: the German word "weil" means "because" and is pronounced the same as "while". Now, if I'm programming late (as I often do), I would be very confused to see "because not done" construct :D Subconscious translation could be a tricky thing ;)

In a company I worked for before we had convention to write all code strictly in English, but comments were supposed to be written in Bosnian (not that is my native language).

Damir Zekić
I think you mean 'fertig' when you say 'vertig'. That would be a reason to write in the language you know best, because this way everyone will just get confused.
korro
You are right, of course :$
Damir Zekić
Damir: I'm actually having more issues with this code because I read it as “while not fertig” which is plain gibberish to me (I *am* German, mind).
Konrad Rudolph
+1  A: 

One thing that's not been mentioned is English vs US-English, so I'll add my 2 pence.

I find it entertaining to fix up comments with English spelling ('center' to 'centre', 'realise' to 'realize' etc), but code fragments should stick to US-English spelling, since that's what other users (or should that be 'uzers') of the code are likely to expect.

Dominic Rodger
I Try to use correct words and verbs for identifier. I verify sometime with a dictionnary but I must admit that I don't care about these details (English vs US-English).
Luc M
I had an afternoon of fun once when I realised that I had documented something as "authorise", but written the code as "authorize". Nobody noticed - they all used "authorize" anyway. So I changed the docs.
Steve Jessop
I consistently make a point of using English spelling. America speaks American, the rest of the world happily communicates in English :-)
harms
In computer graphics, "color" vs. "colour" can be a nontrivial problem 8^\
comingstorm
I'm English, and much prefer English English to American English. Even so, when working on an international code-base, I accept the reality that going around the place "correcting" spelling etc., is just a recipe for creating bugs. No-one will thank you for it.
Dominic Cronin
+6  A: 

On the face of it, in any company, the correct language to use for code is the official internal language of the company: the same language you use for inter-departmental communications.

This might well be English, but if it isn't then it could be because you have non-fluent-English-speakers working in the company, perhaps as programmers, who might need to understand your code. More importantly they need to clearly document and comment the code they write. In a language they don't have fluently this will result in some confusing comments, although code review would sort that out. Those people will of course speak your official language, so it may be easier to stick with it.

But that's just the official line. Even if your company uses French internally, and makes fluent French but not fluent English a condition for all employees, programmers are more likely than the average employee to speak good English. And some day you will hire a hot-shot contractor who doesn't speak French. Chances are this contractor speaks English, perhaps exclusively. So code written in non-fluent English is probably more useful to him than code written in French, and you're paying him considerably more per hour than anyone else in the organization.

I suppose what I'm saying sort of implies that every company should mandate English as an internal language, and require/teach all employees, especially coders, fluent English. But then I'm an English-speaker who on a good day can maybe get the gist of a newspaper in French, a child's book in German, and nothing in any other language. So I'm hardly entitled to an opinion, and I'm inclined to suggest that if anyone in the team is less than fluent in English, you should muddle through in whatever language the team knows best, and be prepared to translate later if you hit problems. I base this on the simple fact that if I was required to write code in any language other than English, I'd do a terrible job of it. So I assume the same is true of the (very small) proportion of French programmers whose English is no better than my French.

I have encountered comments written in French before, in an English code base. The author was French, and presumably wasn't paying attention when he wrote them. I understood them, but I was glad that the Swedish and Dutch guys never did the same thing. It's probably most important to pick a language that everyone can use, because a mix of languages is probably worse than a single language that everyone knows they should improve if it's not their native.

Steve Jessop
+7  A: 

One of the developers on my project was Turkish. I found this bit of JavaScript code and I still have no idea what it means.

function tarihsirasi(t1,t2) {
    ar1 = t1.value.split("/");
    ar2 = t2.value.split("/");

    var bir = new Date(Date.UTC(ar1[2],ar1[1]-1,ar1[0]));
    var iki = new Date(Date.UTC(ar2[2],ar2[1]-1,ar2[0]));
    if (iki.getTime() < bir.getTime()) {
     alert ("Aralık girerken, girdiğiniz ilk tarihin ikinci tarihten daha önce olmasına dikkat ediniz.");
     return false;
    }

Talk about unmaintainable code. I write all my code in English. It's not the only language I know (I am a native speaker, though), but I would hate to leave behind code for other US developers to decipher like this JavaScript function.

Robert S.
It's obvious! If 'iki' is less than 'bir' you have had too much beer and your application starts popping out gibberish messages. Not the first time to see that happen ;)
Damir Zekić
hahaha, I'm Turkish and even I don't understand that code. =)jokes aside, bir means one and iki means two. great variable names =) oh, and tarihsirasi means dateorder. _This_ is why I insist my coworkers write all their code in English.
Can Berk Güder
Is there a turkish "Foo" and "Bar"?
StingyJack
not that I know of. =)) I think bir and iki are as close as you can get, haha =)
Can Berk Güder
This is great one! I'm Turkish as well but I've gotta tell that's one piece of badly written code (as in naming convention) and Can (previous comment) is exactly right it's almost Foo Bar
dr. evil
Also why do you have Turkish text in your alert box (assuming that your project is not in Turkish)?
dr. evil
@Slough, that's the only function that has a Turkish message. I think it was test code that got left in because nobody knew what it was.
Robert S.
Turkish "foo" and "bar" would be "hede" and "hödö", respectively. (They can be concatenated, as well.)
aib
+1  A: 

I work for a French company but we are several English speakers who develop. I think that consistency is the key to maintainability. So a project written in English should always be in English.

That said, I prefer comments in French to no comments at all, at least they could be translated later. Although I do try to stray away from French variable and method names, this is not too difficult even for people little English and they can also refer to existing programs for examples.

ThatBloke
+3  A: 

I'am not a native English speaker and my code is in English. We try to keep domain specific terms in our native language (German), but all other Code is in English. The programmers on the project do all speak English and German, but much of them have a different mother tongue.

It can be often very tricky (and hard to understand) if you translate domain specific terms into an other language.

Since all teammembers do speak(or at least understand) each of the used languages in the code this is perfectly ok.

danimajo
+1 for "domain specific terms in our native language", because they are usually harder to translate (in both directions)
ammoQ
+2  A: 

I'm used to seeing code written with variables and comments in other languages. It makes perfect sense to me for Danish programmers to write using Danish, and for other people in other countries to write in their own language. Since comments can be misleading, it is an excuse not to read them. You do, sometimes, need to get some basic guidance on what the functions do, but the example of Turkish Javascript (posted by Robert S) is only a problem, in my view, because the alert message has not been internationalized. And, if the code was only used in a context where the audience speaks Turkish, that wouldn't be devastating.

I'm a native English speaker with tatty French (and various computer languages) as a second language. But I'd never castigate someone for producing code with variable names and comments in another (non-English, human) language unless there was some standard - de facto or de jure - requiring the code to use English. (The existing code base constitutes a de facto standard; if it uses French, new code and changes should continue to use French. And I'd argue that in most circumstances, the existing code base would override a new de jure standard to use a different language.)

Jonathan Leffler
+3  A: 

At the company I work for here in Norway all code and comments are in English.

  • We use gettext to translate the output to Norwegian. This way we can translate the pages to other languages easy. And the pages are also by default "translated" to English.
  • Makes it easier to hire programmers who aren't Norwegian.
  • Since everything about programming has English words, documentation, examples, help pages, etc, its easier then juggling 2 languages.
  • If it were ever decided to sell the code, we'd have a larger potential market then just Norway.
OIS
than just Norway ;)
Hamish Grubijan
+2  A: 

Several persons mention using the official language of the company you work for. OK but, for people like me, who write mostly free software, software that will be distributed everywhere, and in unforeseen places, broken english seems the most reasonable language for variable names, comments, etc.

bortzmeyer
+4  A: 

One intelligent remark I once saw on this subject is that programming as an artform has evolved to use English in much the same way classical music uses Italian and gastronomy uses French. Knowing enough English to get by is part of our profession.

That being said, there's an interesting phenomenon of programming languages based on natural languages other than English. Naturally, Wikipedia has a page about such languages.

harms
+5  A: 

I'm Turkish, but I write all my code and comments* in English, and I urge my coworkers to do the same.

Now I love my language, and I believe it's much more efficient and expressive than English. I also try to refrain from using non-Turkish words and expressions when I speak or write.

On the other hand, I use all my operating systems, applications, devices, etc. in English, because somehow that feels more natural. Most translations end up sounding weird and stupid anyway.

The same goes for programming. Non-English variable names and comments would only look weird and stupid among English constructs and library functions.

* Of course there's the occasional joke that you just can't make in English, but those are obviously not crucial.

Can Berk Güder
+1  A: 

I worked on a system written in (French) Forth - a language where you build dictionary. Unfortunately the application was written in French and the code was completely unstructured. I got to the stage where I was pointing out errors in the code to the guy that wrote it even though I had next to no French myself.

Tony Lambert
+1  A: 

English is not my native language although I use English in variables all the time, when it comes to the comment it depends on the project. If I've got other people on the project who can't speak english then I try to keep it in the native language (but avoid any none english characters).

Once I've seen a code which variables were written in Japanese! (crazy .NET and Visual Studio)

dr. evil
+2  A: 

Some people are talking about english + one another language. I, at one point, had to work with five at the same time.

I used to work for a local subsidiary of a french multinational company. I maintained code for a application that was nearing its 10th year, originally developed by the german for the french unit and later bought by the brazilians. The application had code written and commented in german, french, english and portuguese. Also, the client was italian, so we had italian technical documents.

Fortunately I can speak English and a little german. French and italian are close enough to portuguese so I hadn't any problem, but it sure felt like reading a recipe.

I made a point of coding/commenting only in english. First, because it's the lingua franca of programming; second, to save others from that unnecessary confusion.

Yeah, globalization they say.

Marcelo MD
+2  A: 

I've tried both ways, and I prefer everything in English now. My main reasons are:

  1. It makes maintenance and reuse easier (and more open to future changes in the business).
  2. Good software literature is in English anyway.
Daniel Daranas
+2  A: 

Of course, it depends on the business, but one aspect that hasn't yet been mentioned is that a company's code base is an asset that's worth money. It's probably worth more money if it's written in English, as this increases the likelihood of being able to find developers and maintainers in the future. Just because everyone on your your current team speaks and writes fluent Swedish/French/Whatever doesn't mean that you should accept this as a constraint for the future. What if you wanted to hire a bunch of Polish programmers tomorrow? What if the owners of the business decide that all future maintenance will be done in Brazil?

Dominic Cronin
A: 

I believe that most people's assertion that code and comments should be in English because future developers might not speak another language is a good example of YAGNI - and it really depends on the project. If the code is written to a French spec, with a French GUI, then any developer who doesn't speak French is worthless to you anyway. For open source projects, all-English makes sense, for most in-house projects it doesn't.

As danimajo mentioned, translating domain terms is a recipe for disaster.

Also, if people write code in a language they are not absolutely fluent in (and if it's not your native language, chances are you are less fluent than you think), that code will be of lower quality because they had to devote some attention on translation issues instead of the application logic, and they'll make mistakes which will confuse maintainers (who, in most cases, are very likely to have the same native language as the original developer).

Michael Borgwardt
Of course, it might be a case of YAGNI. However - lots of people who believe strongly in YAGNI would still choose to internationalise their application, even if the first implementation was for a single language. (If you ever retro-fitted internationalisation, you'll know why.) As you imply, circumstances alter cases, and judgement is called for.
Dominic Cronin
+1  A: 

Personally I am all for using English only. I do that nowadays, but then again, I work for Intel where everyone speaks English. Many people argue that programmers should only use English but the truth is that this is not realistic.

I have worked for small software companies in Brazil where almost everyone else could not speak English at all, so using English identifiers/comments was counter-productive to say the least.

I believe programmers should learn English because without it they will miss on so many things (like Stack Overflow, for instance), but reality -- at least in places like Latin America -- is that the vast majority of people do not speak English at all. Learning can be expensive -- from a Third Worlder's perspective -- and time consuming. Not an excuse, just an observation of the reality around here.

Roberto Teixeira
+1  A: 

Even Dijkstra used English...

Mugunth Kumar
Yeah well, for Dutch people, even of Dijkstra's generation, fluency in English (and probably another foreign language) is normal for a fully educated person.
Dominic Cronin
+1  A: 

I presently work at a company where I saw the perfect example on why one should always code in English :

Most of our team is French speaking and throughout the company`s history we have been mostly a french speaking team. At first they targeted only the local market (also french speaking) so no problem. Then they wanted to expand, here comes the i18n implemented in a hurry (that was 20 years ago) but the team remained french and a lot of comments, class names, table names... large portions of the code is written in French.

Now, they target Chinese market, hired a Chinese team to complement the existing team. I tell you I can think of 50 different ways to spend my days... translating function names is NOT one of them ...

So, point is... you never know where this little piece of software will end up once it is committed with the rest !! besides the language basic instructions are in English, the API ans libraries are all in English... Save yourself the mental overload of having to think in different languages at the same time and keep English throughout !

Newtopian
+1  A: 

I would say that it depends where you have learned to code and who taught you.

Having learned to code in the UK, I'd never dream of writing code in other language, even though Spanish is my native language. Sometimes it's difficult enough to read someone else's code in English, let alone in another language.

But, if you have learned to code in Spain/France/Germany, and your teacher encouraged you to write variables and comments in your native language then you'll go out to the big bad world packed with all these habits.

I'd say that it depends where you learned to code.

Lucas T
+1  A: 

My colleagues are incredible lazy at writing documentation, so I bother them to write at least german comments. I think they are afraid of writing something totaly wrong in English.

Zappi
My english is not very good. It's easy to name variables, classes... but when I write comments, I'm frozen. I'm looking for the right term and it takes me time. It's the reason why I write comment in my native language.
Luc M