31

Is the code written in Japanese? Are filenames in English? What about like a C preprocessor? Is that still in English? Are comments in Japanese?

Examples would be nice too.

Zeno
  • 419
  • 1
  • 4
  • 4
  • 7
    Just like programming in spanish/portuguese/whatever, code should always be written in english. –  Feb 10 '11 at 19:39
  • 1
    @M28 It's a bit different though when you have to use a foreign alphabet. Try to write a simple hello world app using the Greek alphabet for all the keywords. – biziclop Feb 10 '11 at 19:42
  • 3
    @M28: Just out of curiosity: are there any programming languages that have been designed for characters outside the latin alphabet? And if compilers allow for encodings other than ASCII, I guess even Java could be written with all symbols in Japanese, except for language keywords... – FrustratedWithFormsDesigner Feb 10 '11 at 19:43
  • 2
    @Frustrated: [Whitespace](http://en.wikipedia.org/wiki/Whitespace_(programming_language) comes to mind. – Josh K Feb 10 '11 at 19:44
  • @Frustrated Yes, the first example that comes in my mind is Falcon: http://www.falconpl.org/ –  Feb 10 '11 at 19:45
  • @Josh K♦: hehe ok I knew about that one... I was thinking more along the lings of something where the keywords are in Japanese or something. – FrustratedWithFormsDesigner Feb 10 '11 at 19:45
  • I'm not familiar with programming in other languages like Spanish either, so really don't know about that either. But why is it the same as the Latin languages? – Zeno Feb 10 '11 at 19:46
  • 3
    @Frustrated: [Wikipedia knows everything.](http://en.wikipedia.org/wiki/Non-English-based_programming_languages) –  Feb 10 '11 at 19:46
  • @M28: Hm I'm not sure how Falcon answers my question... – FrustratedWithFormsDesigner Feb 10 '11 at 19:47
  • @delnan: you might was well post that as an answer. – FrustratedWithFormsDesigner Feb 10 '11 at 19:48
  • @Frustated Falcon answers your comment, it works with non-latin alphabet and its compiler supports unicode. –  Feb 10 '11 at 19:51
  • @M28: I'm pretty sure Java does too. I later (after you posted Falcon?) updated my comment to ask about languages where the keywords themselves were non-english and in different alphabets. – FrustratedWithFormsDesigner Feb 10 '11 at 19:55
  • This question, BTW, is simply a narrowing of http://programmers.stackexchange.com/questions/1483/do-people-in-non-english-speaking-countries-code-in-english and I vaguely recall a similar question on StackOverflow. – JasonTrue Feb 10 '11 at 22:11
  • @FrustratedWithFormsDesigner: Yes, there are. I've used Greek letters for variable names in Go. As a physicist, I like lambda for wavelength, rho for density etc. Go should be able to handle letters like the German ö, Japanese characters, etc. But I don't know about keywords like "for" and "if". These might be stuck in English for now. – DarenW Mar 16 '11 at 23:31
  • Nobody codes in Japanese. *Nobody codes in English*. If you think you're coding in English just because `if` looks a little bit like the completely unrelated word "if", you have serious problems. – Alex Celeste Jan 16 '15 at 10:23
  • KTurtle, a KDE implementation of the LOGO programming language, can be [translated](https://edu.kde.org/kturtle/translator.php), including language keywords, into the user's language. It's primarily designed for children so removing the natural language barrier is supposed to make it easier to learn. – Michał Kosmulski Jan 16 '15 at 16:35

2 Answers2

23

As someone who has programmed in Japan. I can honestly say that I have seen code in all forms. Most of the cleaner code that I have seen that was intended to be supported only by Japanese programmers had all of the comments and documentation in Japanese.

As for some of the horrendous code that I have seen, I remember seeing Java and (I believe) VB code that actually used kanji or katakana for variable names.

That aside, code tends to look like this

/**
 * これはクラスのコメント
 */
public class FooClass implements Fooable {

    /**
     * オブジェクトのインスタンスを作成する
     */
    public FooClass() {

    }

    ...
}

As for a C preprocessor, I have no idea.

Elijah
  • 511
  • 3
  • 7
  • A preprocessor could be used to translate language keywords to other languages. – FrustratedWithFormsDesigner Feb 10 '11 at 19:55
  • 4
    So is "Foo" an actual English word like "BankClass" or or is romanized? – Zeno Feb 10 '11 at 20:02
  • 2
    Like, would they call `FooClass` `BankClass` or `GinkouKurasu`? – Panzercrisis Feb 24 '14 at 18:55
  • 1
    I know, but in the real world, would they be more inclined to use `Bank` or `Ginkou`? – Panzercrisis Aug 26 '15 at 20:14
  • 3
    @Panzercrisis, that depends on the whims and policies of the developer or team. As I mentioned in my answer, my wife's code tends to use English words in declarations, but she might use the words differently than I would typically interpret them. I don't think there's any one pattern that's dominant. But I'd bet that a developer who is only familiar with the Japanese word for a concept would use that rather than resorting to a dictionary. – JasonTrue Mar 14 '16 at 18:45
  • What's wrong with writing variables in Japanese? I don't mean to suggest something, but it seems like people think that code should be completely in English? – BelgianCoder Feb 03 '19 at 16:55
11

In practice, most programming languages in active use outside of the US use keywords that resemble English, but it's important to realize that for the most part those of us who write code as native English speakers aren't really writing in "English", either.

There are a few dozen languages that actually support non-ASCII-range keywords and these are often designed to reduce the cognitive friction for non-English speakers trying to learn programming.

Additionally, some older implementations of languages that translate code into tokens (not true compiling), can spit out the same code in an editor using the, say, German equivalent; my first experience with Microsoft Office's VBA was like this when I was a student in Germany.

Many English-like programming languages, including C#, Java, and others, now allow variable names and method names in Japanese, as long as the source code is encoded in UTF-8 or another suitable encoding. It wasn't common to have even comments in Japanese in C, however, unless you were using a compiler that supported Shift-JIS or Unicode. String literals in C were almost always escaped using the literal encoding method unless you had an external resource file format to work with, as in Visual Studio.

In practice, many programs written by Japanese teams that don't expect to require maintenance outside of Japan are written with comments or javadoc/docstrings/etc. in Japanese. My wife generally writes code with a sort of Japanese-like English, using terms that didn't necessarily match my own use or understanding of English ("regist" for "post" or "story", regist_date for publication date), and occasional comments in Japanese or Janglish.

Most programs that have an international community around them, that originate in Japan, use some form of English naming convention. See, for example, Matz' source code for ruby.

JasonTrue
  • 9,001
  • 1
  • 32
  • 49
  • What if the project doesn't know if they're going to release the source outside Japan? Like a video game developed in Japan. They sometimes don't know if an English publisher will want to release the game say in the US. – Zeno Feb 10 '11 at 20:13
  • @Zeno - That's internationalizing character strings the user will see. That's important to do even if the code is by and for English-speakers. Comments & variable names & internal language aren't really correlated unless the code is going to be released as an API. – G__ Feb 10 '11 at 20:21
  • Not really, often times video games published outside Japan will include more features so the code is directly changed too. Like Final Fantasy VII included new bosses (Ruby WEAPON) in the US version but not the Japanese version. – Zeno Feb 10 '11 at 20:33
  • Are those new features language-dependent? What's the difference versus just marketing a different feature-set in Tokyo than in Nagoya? – G__ Feb 10 '11 at 21:12
  • Like in the US, people sometimes make assumptions that their app will never be used outside of their country, and that sometimes results in code changes being necessary to release for other markets. But comments rarely need to be rewritten for localization processes if modern approaches to internationalization are used, because code is not generally touched by localizers. – JasonTrue Feb 10 '11 at 21:35