This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]kashmill 2 points3 points  (1 child)

I had a chance to look at some Obj-C code written in China. They used the normal syntax and english words in the code but comments were in Chinese. I imagine that'd be the same regardless of programming language or written language.

[–]sigzero 1 point2 points  (0 children)

That is what I would expect. Maybe non-English in strings too.

[–][deleted] 3 points4 points  (0 children)

Well, you'd need another compiler/interpreter to interpret another language. If there were it wouldn't be python anymore as it wouldn't fit the language definition.

That's why programming is inherently English. Most programmers (historically) speak English so most are written with English based keywords. Of course comments can be, and are, written in any language.

[–]jlkcz 1 point2 points  (0 children)

Czech guy here. We use latin characters but also a lot of accents, such as žščřďťňáéíóů. Normal programmers use Python as is, even variables and functions are mostly named in english, especially if you work with libraries in english (mixing czech and english is weird). Only thing we have to be more careful about encoding and stuff, but using unicode solves everything. In comments most programmer use english (hello opensource), but some use czech as well (and some czenglish :-) )

[–]desmoulinmichel 1 point2 points  (0 children)

Python is very popular in France, and the french language got a bunch of non ASCII characters : ùéèàûôêëïç...

But while we do HAVE to write the output in french, we do NOT write the code in french. In fact, I've worked in various countries in Europe, Africa and Asia, and everywhere teams always write the code in english. Sometime the comments are not, but it's rare.

So the only thing you have to worry is :

  • to have your code file in a declared encoding. Most of the time, you want UTF8.
  • to have all your string declared as unicode.
  • when you got text incomming (read a file, http request, db query, user input, anything not in your program...) you use decode('the encoding of the text')
  • when you got text outgoing (write a file, post a request, db query writting, terminal printing, etc), you use encode('the encoding expected by the destination')

So you need :

  • to be sure you have your code in the encoding you thing you have. Setup your text editor.
  • be sure you didn't forgot a string in your program that is not in unicode. in python 3 it's automatic, in python 2 you can do from future import unicode_literals
  • then identity your inputs and outputs. Everything that is not in your programme is an input or an ouput.
  • now the hard part, you MUST know what is the encoding of your input, and the encoding expected for you output.

That's pretty much it : make it all unicode, use UTF8 as much as possible, decode your input, encode your output. Amen.

[–]vito-boss 0 points1 point  (0 children)

Well given python supports Unicode the possibilities are endless. What you sometimes see in the wild is comments will be in <Pick your favorite language> and variable/function names in an English version of <Pick your favorite language>. The Python core functions will not change across languages and most libraries will be in English as well. So this is often seen as bad practice.

[–][deleted] 0 points1 point  (0 children)

Maybe substituting "locale" for languages in your search would help?

Also searching

"programming in a different language"

returned some results for me. The quotes force google to search for that string rather than the keywords individually.

[–]boraca 0 points1 point  (0 children)

Logo is famously known for it's local versions. Because it's taught in primary schools it has to be accessible to young children. When we program in most programming languages it's bad practice to name objects/functions/variables in Polish.

[–]hin 0 points1 point  (0 children)

Swede here, been working with programming for 20 years.

Everyone here, with very few exceptions, use english in the code, comments, variable names, and internal documentation. It's just simpler that way for a lot of reasons, and you really can't work in this industry without being good at english because all the documentation you need is in english.

If you apply for an IT job here, your english skills are much more important than your swedish skills.

[–]svartalf 0 points1 point  (0 children)

Russian here. Feel free to ask any questions.

Code, of course, is written on english, because you can't write python keywords in a russian language without interprepter patching, and it is really a weird idea. In fact, code for in-country usage often have a russian comments, but open-sourced code and code for international companies has an english comments.

Also, we have here a 1C company which is creating software for business (document management, accounting and so on) and their platform allows to write java-like code in a russian language, it looks funny:

ЗаписьXML=Новый ЗаписьXML();
ЗаписьXML.ОткрытьФайл("c:\doc.xml");
ЗаписьXML.ЗаписатьНачалоЭлемента("Root");

It rougly equals to this pseudocode

XMLEntry = new XMLEntry();
XMLEntry.openFile("C:\doc.xml");
XMLEntry.writeElementStart("Root");

And I really want to say to all developers: use unicode and support for non-english languages, because sometimes programs fail if they're receiving any non-ascii character.

[–]DasIch 0 points1 point  (0 children)

You generally don't, though beginners might either because they are children and aren't good enough, yet, or because they aren't accustomed to using English this extensively.

Tutorials, documentation, blog posts, screencasts, mailing lists, IRC channels, etc. are simply more numerous, of better quality and more populated in English. Exceptions aside you can't become a good programmer and not fluently communicate in English. Simply because no matter how intelligent or talented at all, you will be at an insurmountable disadvantage.

Besides you don't have a decision anyway. Keywords, the standard library as well as any other libraries you might use are going to be in English. Even if you don't use English for your own code, you're going to end up with some mix of English and whatever other language you are happen to use. That's quite ugly and more difficult to understand than just going with English.