7 ms·
One thing I'm completely ignorant of is how to people from countries where non-latin alphabets are write code? Eg if you're Chinese, Arabic even Russian do you
by rb808 9y ago
One thing I'm completely ignorant of is how to people from countries where non-latin alphabets are write code? Eg if you're Chinese, Arabic even Russian do you have to do everything in English and English characters?
I'd hope there is a Unicode mapping into other characters - is there any language that supports this? Even for libraries would be nice.
- Carioca 9y agoAt least here in Brazil it's relatively common to mix English defaults and Portuguese variable names. So a Django class declaration would look something like: class Pessoa(models.Model): idade = models.IntegerField() nome = models.CharField() Then some things wind up having mixed-language variable names: class PessoaForm(forms.ModelForm):
- scardine 9y agoPortuguese is rooted in Latin so it uses the Latin alphabet, the parent was concerned about other alphabets. Off course there are the accented characters but those are just transliterated to ASCII. Even when the language accepts unicode identifiers (like Python or Javascript) they are not transliterated to ASCII so "função" is not the same as "funcao". Everybody just sticks with ASCII for identifiers (occasionally people throw the Greek letter for pi or lambda in a formula but not on my watch). The only thing more awful than these "Portunglish" codebases are Brazilian projects trying to stick with English names only. These are often full of misleading translations - for example using "Budget" instead of "Quote" because in Brazilian Portuguese the word "Orçamento" means both. Very confusing.
- FanaHOVA 9y agoKeyboards switch between the two easily. I've worked with a couple Russian guys and sometimes they'd just write cyrillic jibberish in Slack because they forgot to switch keyboard :) One of them is a really big contributor in the Ruby open source scene, he has no problems switching back and forth.
- jakevn 9y agoIt probably varies based on country, team, and nature of the project. For Chinese OSS projects on Github, I notice that functions/vars/etc. are in English, but comments are in Chinese.
- dx034 9y agoMaybe using single characters (e.g. chinese characters) instead of words for keywords is more efficient to type and read for programmers. Not sure how typing compares but it could give code more structure. Does anyone know how governments in China, Japan or Korea handle this? Do they try to use non-english programming languages?
- blackguardx 9y agoSingle chinese characters are inputted with more than one key press on the keyboard, so it won't be much different. You can test this by changing your input method to Japanese or Chinese. At least in Japanese, the sound of the character is typed out using english letters (romanji) and various options are presented for autocompletion. You are right that reading characters is probably faster, though.
- seanmcdirmid 9y agoPinyin input for Chinese is similarly phonetic. Supposedly there is a method popular in Taiwan based on strokes. Reading characters is a bit faster, but only because you had to memorize 10,000 of them already. People reading English will similarly chunk many of the words they are familiar with so that they are not so much read as they are recognized.
- amyjess 9y agoThere's also a Taiwanese system called bopomofo or zhuyin, which is basically a Chinese version of kana.
- hangonhn 9y agoThis is also a stroke system (Wubi) that's more popular and faster in China too. Maybe it's a related system to the one in Taiwan. Pinyin makes sense only if you're already familiar with the Latin alphabet and how they sound. Those are literally foreign concepts to the Chinese.
- 9y ago
- memco 9y agoCan't recall exactly where I saw it, but one of the major language designers (I think for Perl) was talking about how there was a plan to abstract some things like quotes such that a character used to quote a string in any spoken language would be a valid way to declare a string. This didn't seem to go so far as to also allow this for keywords, but for symbols the thought was that you could simplify things a little bit for others by not requiring only symbols common to an english keyboard.
- liveoneggs 9y agoin perl 6 you can quote strings in quite a few ways! https://docs.perl6.org/language/quoting https://docs.perl6.org/language/quoting "Quoting" is all defined inside of a sub-language called "Q"
- vidarh 9y agoRuby has pretty much the same flexibility. "%" followed by almost any non-alphabetic character starts a quoted string. But most then become the quote character. If the quote character is at least <,(,[ or { then the end-quote character is the corresponding >,),] or }. These are all equivalent: %<x> %"x" %{x} %!x! Unfortunately the rules are loose enough that even space is a valid quote character. So this too is equivalent to the above: % x ("% x ")
- sethrin 9y agoOne more equivalent expression: ?x A question mark followed by any other single character is treated as a string literal containing that character.
- b2gills 9y agoNo it doesn't have the same flexibility. Perl 6's string quoting sub language has various feature flags that you can turn on or off. Here are a few of the basic ones shown in valid code (comments and newlines included) # start quoting with no features enabled # (not even backslashing the delimiter is enabled) Q :scalar # enable $foo :array # enable @foo[] :hash # enable %foo{} :closure # enable { 12/3 } :function # enable &foo('bar') :single # turns on backslashing the delimiter :backslash # enable \n :!exec # turn off executing it (redundant) :exec(0) # another syntax for turning off a feature {…} # various delimiters are allowed (generally punctuation) There are shorter variants of each of the feature flags. :c => :closure I would like to point out that the parsing of the :closure and :function part of the sub language is reentrant. (Actually most of them add some form of reentrancy, it is just harder to show it for the others) "a b &foo( "c d &bar( "baz" )" )" Note that this reuses the base Perl 6 parser, and that is why it is reentrant. There are shortcuts for regularly used forms 「」 =:= Q[] '' =:= q[] =:= Q:q[] =:= Q:single[] "" =:= qq[] =:= Q:qq[] =:= Q:double[] =:= Q:b:s:a:h:c:f[] =:= Q:backslash:scalar:array:hash:closure:function[] The ability to turn off features can be useful qq :!c [a {\n b\n} c] # { and } don't form a closure here I would like to point out that the :foo syntax is used everywhere in the language for named parameters to routines and operators (most operators are implemented as subroutines) :foo =:= :foo( True ) =:= foo => True :!bar =:= :bar( False ) =:= bar => False :$baz =:= :baz( $baz ) =:= baz => $baz If the delimiters are paired () <> {} 「」 «» “” ‘’ you can double up on them. q<FOO> =:= q<<FOO>> =:= q<<<<<FOO>>>>> This is useful to avoid having to backslash a delimiter within the string, or trying to find a delimiter that isn't in the string. q<< <a> >> =:= q' <a> '
- astonex 9y agoAt my Korean company, all code is written in English and comments are in Korean/English. On osx, capslock is used to quickly switch between languages.
- deleted 9y ago[deleted]
- wingerlang 9y agoCapslock with custom bindings? The default way to switch is control + space.
- ivm 9y agoYes but it's not comfortable for writing in multiple languages. I use Capslock both on Windows (Punto Switcher) and Mac (Seil / Karabiner Elements).
- astonex 9y agoIt's not a custom binding. It's a default option offered by osx https://i.imgur.com/uJo5XUj.png https://i.imgur.com/uJo5XUj.png
- wingerlang 9y agoStrange that I've never seen that before. To bad it only toggles between two languages (I have 3 setup)
- Brometheus 9y agoI'd like to know how you do that with capslock, too :D
- astonex 9y agoIt's a default option offered by osx https://i.imgur.com/uJo5XUj.png https://i.imgur.com/uJo5XUj.png
- rauanm 9y agoIt's not a matter of alphabet because people still learn programming languages from English books. Pretty much nails it: https://temochka.com/blog/posts/2017/06/28/the-language-of-programming.html https://temochka.com/blog/posts/2017/06/28/the-language-of-p...
- supermdguy 9y agoThanks for the link
- drdaeman 9y agoRussian reporting in. I think everyone here who writes code knows Latin alphabet. It's just a basic requirement - it's a given that if you want to code you'd better learn English, let alone alphabet. In schools, kids learn to code using Algol-like language with identifiers in Cyrillic (essentially, Russian) abbreviations, e.g. "нц для i от 1 до n" rather than "for i := 1 until n do", but even here you see Latin letter "i" ;) However, it's not uncommon to just go with e.g. BASIC or Pascal. There is also de-facto standard accounting & ERP software producs from 1C which use Visual Basic-like language with Russian identifiers like "Константа" for "Const", etc. It's widespread in its domain, but not used anywhere else. 1C programmers are sometimes (half-jokingly) considered to be of a different caste. Sort of like COBOL programmers, maybe, or - probably closer - SAP developers. I don't think anyone has any serious issues with basic English language for identifiers. Literature, documentation, discussion - here, language barriers do matter (a lot!), but not for programming languages themselves. That is, unless someone wants to show off as a true hardcore Russophile, of course. Code comments, identifier names and e.g. log messages are different matter. I don't think there is any common practice for this - more like a matter of personal preferences. Some try to stick with English, some use Russian or transliterated Russian (mixing it with some English) liberally so it's not uncommon to see something like `log.Error("Дом не найден %s, %s: %s", ulica, nomerDoma, responseText) /* TODO: Добавить поиск лучшего совпадения */` in their code.
- vidarh 9y ago> some use Russian or transliterated Russian (mixing it with some English) liberally so it's not uncommon to see something like `log.Error("Дом не найден %s, %s: %s", ulica, nomerDoma, responseText) /* TODO: Добавить поиск лучшего совпадения */` in their code. This gives me nightmares of dealing with an old patched Joomla install, where the developers had managed to bring in plugins etc. that used multiple inconsistent encodings in comments, so you could get all of the code to render correctly with any single terminal setting.
- drdaeman 9y ago> old patched Joomla Been there, saw that. The quoted part alone is way more than enough to give nightmares. I bet, encoding issues is just the icing on the cake. ;)
- Gudin 9y agoI am from Slavic country and writing code in native language looks amateurish (that's the general thinking).
- supergreg 9y agoSame in Spanish. At my company we use only English for code, even comments. And are trying to push for jira tickets to be written in English only as well. At least among the developers. Can't keep managers from using Spanish.
- philbarr 9y agoI'm the only English person working in a German team at the moment, and their codebase takes letters like "ö" and makes it "oe". I think there are a few like that. Personally I prefer it when they use English obviously (I don't speak German), but it also means you don't get ridiculously long identifiers.
- wastewaste 9y agodon't you as a programmer feel familiar with longidentifiers. Would you prefer in dent a-gogo ers? Yes, my latin is lacking.
- patio11 9y agoIn Japanese companies that I've worked at, the convention is using English words for programming concepts, using Japanese words transliterated into English for business concepts except where the English word is easy and obvious, and using a pedantic level of Japanese code comments to signpost for those developers who are less confident in their English ability. e.g. // 教科リストを取得する。 String[] kyoukaList = getKyoukaList(); (Japanese university backend systems have two concepts of "a subject", with kyouka being a subject like math is a subject and kamoku being a subject like Algebra II is a subject.)
- yeukhon 9y agoAs far as in my experience, no. Comments can be Chinese for ease of reading, but Chinese developers work with the usual programming languages out there: C, C++, c#, .NET, Java/Scala, Python, Javascript. Honestly there is no reason to use a Chinese programming language (there are such). If you work for an international companies, then English is the preferred language for comments. Back in 2000s, text editors often did not default to UTF-8, so if you are from Taiwan for example, your file might be in big5 encoding, and would require a change if open by an editor in utf-8. Now this is a rare practice.
- cepp 9y agoWorked at a Chinese company in Shanghai before. Everyone on my team could read/write but not speak English. It is most common that people would write code in English but use Chinese for comments and documentation (both internal and external). We all used Sogou which makes it easy to make a hotkey to easily change between Chinese pinyin input and English. I am lead to believe this usage of English for code and Chinese for comments is quite common given the code I've read from public repositories and other companies we worked with.
- oshoham 9y agoقلب is a Scheme-like programming language that is written entirely in Arabic. http://nas.sr/%D9%82%D9%84%D8%A8/ http://nas.sr/%D9%82%D9%84%D8%A8/ https://github.com/nasser/--- https://github.com/nasser/---
- nine_k 9y agoWow! Right-to-left languages don't just have to alter the glyphs, they also face the questions of different indentation, different argument order (does `a->b` still express the same meaning?), etc.
- pmontra 9y agoI looked for some Chinese developer on GitHub. This is the most Chinese source file I found https://github.com/hzxie/city-picker/blob/master/city-picker.js https://github.com/hzxie/city-picker/blob/master/city-picker... Variables in English, strings in Chinese when they have to (it manages a list of city names). I could work on that code and I don't know Chinese. This is more or less what I see in code here in Italy. Sometimes somebody slips a variable name in Italian but among pro developers it's limited at cases when there is really no obvious English counterpart. Example: legal terms, they tend to be very specific and you'd need a lawyer to translate them correctly. Accounting too.
- nine_k 9y agoChinese is hard to transliterate to English, because there's no nice way to express the tone, and even with tones, there's a number of homophones. To express a precise meaning, you either use hanji, or proper English words. Other languages, like Russian or Japanese, can be transliterated pretty unequivocally, so transliterated identifiers are often found in source code, especially in business-related identifiers where a precise translation may not even exist.