25
$\begingroup$

The students I teach at a middle school in Beijing normally have a limited vocabulary. They struggle to come up with decent variable names and function names. Most of the time they just name variables as a, b, and c, and function names as ab, ac, and ad. Considering their vocabulary, telling them to use a meaningful name seems pointless.

Sometimes kids will use pinyin, a system to spell Chinese Characters with the Latin alphabet based on their pronunciation, to name the function, e.g. fabs in Chinese pinyin is "jueduizhi", so instead of fabs(x) they call it jueduizhi(x). That seems to be a workable solution although it looks strange at first.

I am a non-native English speaker myself but I have forgotten how I got through this obstacle. But I know naming may be hard for native English speakers too, otherwise, there wouldn't be the two hard things joke. The answer given by @bta gives me valuable input and also reminds me of my Objective-C days that Apple has some guidelines for naming, e.g. "The use of 'get' is unnecessary, unless one or more values are returned indirectly." But that is another topic.

Does anyone have a similar situation to mine (not necessarily Chinese)? Any suggestion on how I teach these students to name their variables and functions better? Or does it not matter at this stage (when they try to learn the basic programming concepts)?

P.S. I would like to add this article as an anecdote to my question: Learning Japanese the Rubyist way. And it would be interesting if I can get someone from Japan to answer this question.

$\endgroup$
22
  • 18
    $\begingroup$ What is wrong with pinyin? The names make sense to them if they are descriptive of the semantics of the program. English speakers don't need to be mollified. $\endgroup$
    – Buffy
    May 29, 2023 at 15:11
  • $\begingroup$ A, for starters, just some smart kids come up with this idea and I am not sure if it Is worth promoting the idea. B, it is not easy to use pinyin to name them in a consistent way, e.g. loop can have several translations in Chinese, then each with a different pinyin. C, some function/variable names we have gotten used to like worker/manager/factory, when translate to Chinese really sound strange in code. In a word I am not sure if it is a good idea. $\endgroup$ May 29, 2023 at 15:23
  • 6
    $\begingroup$ I switched from my native Danish to English in my code many years ago, because (1) when you look up solutions they will often be in English; (2) standard designs (patterns) come with a well-defined English vocabulary; (3) libraries are all in English, mixed with other languages the code becomes hideous. Solution: Use ChatGPT or similar. E.g. ask it "What is a common term for a worker in a bank". $\endgroup$ May 30, 2023 at 9:25
  • 9
    $\begingroup$ @Qiulang邱朗: It depends. If you are investing in their long term ability to learn how to develop software, then teaching them to get familiar with the lingua franca of the software development world is going to make it significantly easier for them to access learning resources. If this is an introductory class for students who have not yet committed to wanting to learn software development, then needing to get familiar with English is an unnecessary hurdle to understanding a very basic introductory principle of software development. The context of your curriculum matters. $\endgroup$
    – Flater
    May 31, 2023 at 4:14
  • 2
    $\begingroup$ @SpehroPefhany I would rather them write hanzi comments but still use English names for variables and functions. $\endgroup$ Jun 1, 2023 at 6:20

10 Answers 10

19
$\begingroup$

The point of good variable/function/class naming is to express problem semantics to readers, including the programmers. If your readers are primarily French speakers, use good French naming for everything.

Unfortunately, most programming environments don't support Chinese and Japanese (or Navajo or ...) characters directly, or it would be proper to use those. But students should be encouraged to find names in their own language that correctly represent the intent of the program item and then, if the programming system won't directly support it and will only accept, say, Latin style alphabets, then a system like pinyin should be fine.

I'm assuming, however, that a reader, reading pinyin will associate the word(s) with the right concept and that the translation doesn't lose too much actual meaning.

Maybe the problem is yours if you aren't a native (-ish) Chinese speaker. But I shouldn't have to use French words unless I were writing for a French speaking audience.


Caveat: If a language can be written with unicode characters then large subsets of Chinese and Japanese and some others can be directly used. Java is an example. IIRC, though, keyboard entry is complicated.

$\endgroup$
14
  • 6
    $\begingroup$ Contrary to the practiced opinion of native English-speaking programmers, English is not the language of programming. Allow, even encourage, the students to use the pinyin-ised names for what things are, or do in the language of the programmer. It would do my heart much good to have all our "languages" localised as well. I'd love to see a yóuyú or zeon loop in some clean code. $\endgroup$ May 29, 2023 at 17:39
  • 23
    $\begingroup$ While I, as a German software developer who's been in the industry for 40 years, strongly disagree with using anything but English in "real" code, I think there is a difference between learners and professionals. Learning to find good variable/method names is much more important than learning to find English names, and switching from good Chinese to good English is much easier than switching from bad names to good names. Don't rate them on their English skills, only check if the name they come up with is a good description of what the thing is used for. $\endgroup$ May 30, 2023 at 18:17
  • 3
    $\begingroup$ @quarague As my employer realizes quite painfully, predictions are difficult, especially when they concern the future ;-). If your code base lives longer than a handful of years, chances are it will be maintained by people who don't speak German at all but read English well enough to understand English code. Note that this may well happen on German soil (as if that had any relevance these days, but still). Your company is myopic. $\endgroup$ May 31, 2023 at 17:31
  • 3
    $\begingroup$ I was told twice quite strongly to write comments, variable names, function names in German, and each time I ended up translating everything into English. $\endgroup$
    – gnasher729
    Jun 1, 2023 at 0:35
  • 2
    $\begingroup$ @quarague I'll give a contrasting example: A German company produces trains with German workers in Germany for DB following German regulations. They are audited by TÜV and Eisenbahnbundesamt. 20 or 30 years later they are producing trains for a world market following European regulations with an internationally distributed team, and parts of the code base and documentation are in German. Perhaps not such a big deal in the great scheme of things, but: The default should always be English unless legal requirements forbid it ;-). $\endgroup$ Jun 1, 2023 at 8:56
7
$\begingroup$

Not an educator but a CS student, reading your description of the challenges your students face when it comes to naming variables and functions resonated with me. As a non-native English speaker myself, I have experienced similar situations as a student.

I am originally from Slovenia and moved to Seattle to pursue a major in Computer Science. English not being my first language, I initially struggled with expressing my thoughts effectively in programming. However, one of my professors shared a valuable insight that I believe might apply to your students as well. They emphasized that as long as the code is logically sound and the purpose of variables and functions is clear, the exact choice of names becomes less crucial.

Given the limited vocabulary of your students, it may seem challenging to encourage them to use meaningful names. However, it is important to emphasize the logical clarity of their code rather than solely focusing on the names. Encourage them to use naming conventions that make sense within their context, such as pinyin in the case of Chinese students. While it may sound unusual, it serves its purpose of conveying meaning within their linguistic capabilities.

Furthermore, you can gradually introduce additional vocabulary to expand their options for naming. Incorporating activities that promote vocabulary development and discussing the importance of meaningful names can help them gradually improve their skills. Might be a shot in the dark but you could potentially introduce them to Metasyntactic variable names

One possible solution could be documenting code, nothing too fancy but just adding a comment above. Its purpose is to explain what it does. Note that programmers might go for a different style of documenting their code. I would suggest not "dumping" everything on them at once (speaking from experience I hated it at first, but now I see why it's important), but introduce them to a simple one-line comment. Later on, you can tell them to list pre and post conditions and even invariants

Example:

void swap(int *num_1, int *num_2)
{
    int temp = *num_1;
    *num_1 = *num_2;
    *num_2 = temp;
}

Now the code above is pretty much self-explanatory, it takes in two integer pointers and swaps them. It arguably needs no documentation.

Now let's look at this example:

void ab(int* a, int* b)
{
    int c = *a;
    *a = *b;
    *b = c;
}

This is still somewhat self-explanatory but without prior C++ or programming knowledge someone wouldn't know what's going on. To solve this problem we could simply do something like this:

// {Zamenja 2 stevili} (Slovenian)
// {Translates to: Swaps 2 numbers}
void ab(int* a, int* b)
{
    int c = *a;
    *a = *b;
    *b = c;
}

Or something like this:

// {
// desc: Zamenja 2 stevili (Slovenian)
// param: a -> pointer na prvo stevilo
// param: b -> pointer na drugo stevilo
//
// English translation:
//
// desc: Swaps 2 numbers
// param: a -> pointer to the first integer
// param: b -> pointer to the second integer
// }
void ab(int* a, int* b)
{
    int c = *a;
    *a = *b;
    *b = c;
}

Or if you want to be fancy and use doxygen

/**
 * @brief Zamenja 2 stevili (Slovenian)
 * @param a pointer to the first integer
 * @param b pointer to the second integer
 */
void ab(int* a, int* b)
{
    int c = *a;
    *a = *b;
    *b = c;
}

Now this results in some code that is a little more readable and someone else might have a better idea of what's going on.

On that note I would like to add that naming variables like s or r and so on is considered bad practice, this is the stuff they do in code-golf and dynamic programming, what I presented is only a shorthand solution and not a long term one.

Edit: I'm assuming you all speak the same language and there is no language barrier.

Best of luck in your teaching career.

$\endgroup$
9
  • $\begingroup$ Thanks for sharing your story, as for you I would recommend using github copilot, one of its selling points is to help non-native speakers to come up with good names. lol $\endgroup$ May 30, 2023 at 6:12
  • 3
    $\begingroup$ I don't see why you can write "swap" in the comment but not as the method name. You still use pointers instead of references? Please, dear student, learn modern C++, not C. $\endgroup$ May 30, 2023 at 16:43
  • 8
    $\begingroup$ Sorry, but I don't like this at all. What if you have 576 different functions, with names from aa to zz - how many of those names can you remember, and how often will you confuse them? (This reminds me of the old days when I wrote CATIA V4 macros, with a library of several hundred function names, all of them some 6 character abbreviation because that's what the linker was restricted to). The name of a method should be clear enough so you can infer what it does when you read the calling line without having to resort to any documentation. $\endgroup$ May 30, 2023 at 18:25
  • 2
    $\begingroup$ @ThomasWeller Despite some similarity in their names, C++ is not the up-to-date C or even a newer version of C. C is a perfectly good language in its own right. $\endgroup$
    – Rosie F
    May 31, 2023 at 15:41
  • 2
    $\begingroup$ @RosieF: sure, I know. The term C++ is used in the answer. I just cited it and compared that declaration to the code associated with that label. $\endgroup$ May 31, 2023 at 21:04
6
$\begingroup$

Why not use Chinese directly?

Here's a Python 3 script with normal ASCII, Devanagari (Hindi) and Chinese. This is both in identifiers (variables, function names) and also in strings.

Table

Ive used google translate used to make this table since I know exactly zero Chinese!

English (ASCII) Hindi Chinese
fool बेवकूफ 傻子
name नाम 姓名
unknown अजाना 未知
Hello नमस्ते 你好
x एक्स (transliteration) x (as is)

Multilingual code

Note the code below is rather poor on many counts! It's just a couple of lines to demo Python doing multilingual strings and identifiers.

# ASCII
def fool(unknown): #  fool is to make foo translatable!
                   #  normally I'd use x for unknown
    name = input()
    for x in range(4):
        print("Hello %s %d %s" % (name, x, unknown))
        
# Devanagari
def बेवकूफ(अजाना):
    नाम = input()
    for एक्स in range(4): # literal transliteration of x
        print("नमस्ते %s %d %s" % (नाम, एक्स, अजाना))


# Chinese
def 傻子(未知):
    姓名 = input()
    for x in range(4): # Ive no idea about transliteration!!
        print("你好 %s %d %s" % (姓名, x, 未知))

Here's a session showing ASCII and Chinese usage

>>> fool(42)
rusi
Hello rusi 0 42
Hello rusi 1 42
Hello rusi 2 42
Hello rusi 3 42

>>> 傻子(42)
习近平
你好 习近平 0 42
你好 习近平 1 42
你好 习近平 2 42
你好 习近平 3 42

Note 1

There are reasons for having strong reservations for how unicode has been adopted (but not adapted!) into Python -- and for that matter most modern languages.

Here's a Python (3 only) program.
Note: Its Python 3 only not 2 which will immediately give syntax error on the 2nd line!

#! /usr/bin/env python3
A = 1
Α = 2
А = 3
# The 1 and 2 should be overwritten by the 3 right??
print("And now the miracle [A, A, A] is %s" % [A, Α, А])

And a run:

~:$ python3 unipython.py 
And now the miracle [A, A, A] is [1, 2, 3]

So Python has A being 1,2, and 3 at the same time?!?!

Strange aint it?

Well they are not 3 A's but one Greek alpha, one Russian (Cyrillic) A and one good ol ASCII A! Who'd have guessed?!

Note 2

As pointed out in other answers and comments unicode identifiers is the norm not the exception nowadays.

Here's C (gcc). Seems to work well enough

#include <stdio.h>
int foo(int x)
{ return x + 1;}

int फू(int अ)
{ return अ + 1;}

int main()
{
  printf("Hello %d\n", फू(42));
}

Note 3

As said above the norm nowadays is that languages support unicode source code. However the nuances across languages is a veritable worm-can.

Eg in Python flag and flag are the same.
In Haskell they are different

More Philosophical objections

Ive shown above that Python (and many other languages) will allow user-defined variables/functions/classes to be from a vastly wider character set than ASCII.

What about builtin functions/types/classes?

Well you could introduce a 'translation-library' that maps Chinese versions of the 50 most used library entities into Chinese.

Laborious but doable

But then what about keywords — if,while,def,class...?? More laborious — recompile Python with all these keywords localized.

Does it stop here? What will you do when your kids need to progress beyond your classes to reading the docs?

All of this is possible but as you go further afield from my toy examples above it quickly gets tedious and intractable.

OTOH none of these are rhetorical questions. With 1.4 billion population, China could dedicate a couple of thousand to heavy-lifting the localization effort.

So at a single individual level you need to think through where you draw your lines...

Personal Note

At a more personal level I strongly believe that beginning students should not be made to break their heads over large ugly real world languages like Python/C++/Java but learn to experience the richness of programming in a controlled baby nursery — which in your case would mean not burdening your kids with programming and a foreign language simultaneously.

Full Languages List

Apart from Python, C, Haskell that Ive talked of above what of the dozens of other languages? Rosetta code has a conspective list

References

Here are some Python 3 references that may be useful

  1. Python identifiers lexical structure
  2. The Python Design Document
  3. General Python Unicode Howto
  4. The mailing list discussion (started by a French-Japanese-English trilingual)
  5. Unicode letter categories — not Python specific
  6. Unicode categories and CJK ideograph complications
  7. My own thoughts on programming using unicode — can be whimsical!
$\endgroup$
9
  • $\begingroup$ The thought never occurred to me. I need to do some research first $\endgroup$ May 31, 2023 at 10:22
  • $\begingroup$ Ive added some links/references that you may find useful @Qiulang邱朗 $\endgroup$
    – Rushi
    May 31, 2023 at 10:35
  • $\begingroup$ Speaking of homoglyphs ("AΑА"), it is Unicode to be blamed that identical characters are duplicated with distinct codes. $\endgroup$
    – Trang Oul
    Jun 1, 2023 at 9:44
  • $\begingroup$ @Qiulang邱朗 Are the characters in my answer 'Hanzi'? Since I've no idea what's hanzi, simplified, pinyin and what not I just left the vague 'Chinese'. If Hanzi is more accurate I'll change accordingly $\endgroup$
    – Rushi
    Jun 1, 2023 at 11:32
  • $\begingroup$ @TrangOul Unicode blamed for homoglyphs. Lets grant that. What will you do? What do you do about war, disease and death? As the saying goes "Sun, moon and taxes" is fait accompli. Likewise unicode. OTOH I don't think blaming unicode makes sense. ASCII was made by techies for techies. Unicode was made by techies and linguists etc for the world. At 3-4 orders of magnitude gap from ASCII to unicode, expecting the same (techie) attitude to work will not. Specifically, prog. languages should opt out by default, opt in with explicit decl/pragma — like html's charset declaration $\endgroup$
    – Rushi
    Jun 1, 2023 at 11:35
5
$\begingroup$

I'll be provocative: English is the lingua franca of computer science. Ideally, every CS professional should be able to understand basic English technical texts. At a minimum, a software engineer should be able to write and read programs with English variable names and basic comments.

I understand that the vocabulary of your students is limited; it is the job of the institution at which they learn to improve it to the minimum described above. If possible, the programming course should be accompanied by a 1-or 2-hours/week language course providing the specific vocabulary needed for the programming tasks. If that's not possible, fill the gap yourself. Simple English is incredibly simple, certainly from a Chinese perspective. Your students can already read the Latin alphabet. What's needed on top are a few dozen words, plus a few words of the respective problem domain for each programming task. Modern IDEs even have spell checkers.

I also understand that I may be narrow-minded and have it backwards: I may live to see Chinese programmers making the same claim with respect to Chinese. But we ain't there yet, so do your students a favor and require English names for variables and functions.

$\endgroup$
8
  • 2
    $\begingroup$ English is simple?!?! See. More seriously, I don't dispute that every programmer in the world of 2023 will be better off for better english. I dispute that it needs to be an added burden to 10-12 yearolds $\endgroup$
    – Rushi
    May 31, 2023 at 15:52
  • $\begingroup$ @Rusi 10-12 yearolds, no. University students using their native language when working with established codebase (written by me, not an English native) that uses only English - absolutely. (true story) $\endgroup$ May 31, 2023 at 16:00
  • $\begingroup$ @VladimirFГероямслава don't get (parse!) your second sentence. Absolutely what? $\endgroup$
    – Rushi
    May 31, 2023 at 16:01
  • $\begingroup$ @Rusi Middle school ranges from 10 to 16, I think. True, it would be wanted much for 10 year olds, but perhaps not for 14 or 15 year olds (they would really profit from a few words of English, not only in CS). $\endgroup$ May 31, 2023 at 16:27
  • 1
    $\begingroup$ @Rusi As to your humorous Twitter link: None of the words are needed for programming (unless they appear in the subject domain), and pronunciation (the topic of the post, and problem for many learners) is irrelevant in any case. $\endgroup$ May 31, 2023 at 16:29
3
$\begingroup$

Names should be descriptive for the audience of the source code. If everyone who looks at that code understands Chinese, there is nothing wrong with using Chinese names, and if you use a programming language that struggles with Chinese characters (do such languages still exist?), you can always transliterate to latin characters.

Alternatively, they can use English. In the age of machine translation, translating a term doesn't take much time. Even before machine translation, online dictionaries were a thing. Open the website, type your word, press Enter, and behold a set of translations to choose from :-)

It can also make sense to mix these approaches. In many programs I have written, I used English for IT concepts, and German for business concepts (the requirements document was in German, but the software libraries we used were in English). It may look weird to mix languages, but it worked very well. After all, the purpose of naming is to clearly convey information, not dazzle the audience with your mastery of the literary arts.

(What one shouldn't do in professional code is mix languages arbitrarily, switching seemingly at random. The same thing should have the same name throughout the entire source code)

$\endgroup$
3
$\begingroup$

In my experience, it is in general hugely unreasonable to expect non-native middle schoolers to have any decent vocabulary of English. Granted, the English used in programming is not English in its entirety but it is still a lot to learn. Pinyin works fine for now, let them be.

To put things in perspective, non-native middle schoolers may be tested on 1000~2000 English words. Obviously not everyone will know all of them, and even less of them well. Even if English used in programming is very limited, there might still be a few hundred words that is commonly used. Asking the students to know them well is too much.

But make no mistake, English is the de facto standard language, and it should be made clear to them they should learn some English if they want to pursue programming further. The reasons why are innumerable

Official documentation, books and tutorials

Not knowing the vocabulary will limit the resources available to you. It is simply a fact that English resources are currently the best.

Googling and Stack Exchange

The fact that you're asking here, instead of say zhihu, is proof that knowing English is a great advantage. If you google in English, you get Stack Overflow. You'd be surprised how many people googled the wrong keywords, found nothing and gave up.

Standard libraries and builtins

These are not changeable and all of them relies on English. For example, in C++ it is required that your member functions are begin and end to enable range based for loops.

Tooling

There are tooling that relies on how English works. For example, pytest uses test_* and Test* as a signature that the objects are items for testing purposes.

The list goes on. As you might imagine, software really really cares about consistency.

Using Unicode characters is even worse for tooling:

  • Regex support for non-ascii characters is usually poor to non-existent.
  • Go (the language) uses uppercase letters to indicate exported names.
  • The way whitespace plays with different languages is hugely variable.
  • Languages going from right to left is likely impossible to work with for many tools.
$\endgroup$
2
  • $\begingroup$ Sometimes I wonder why everything is in English. Then I realise, the non English stuff does not come up in by searches. $\endgroup$ Jun 1, 2023 at 18:34
  • $\begingroup$ The only thing I can add is to these words "The fact that you're asking here, instead of say zhihu..." I asked here instead of zhihu or quora is because I am an active user of SE and I think it is the best, say far better than quora, although I hate close-vote and down-votes without any comments. $\endgroup$ Jun 2, 2023 at 1:32
3
$\begingroup$

Native English-speaking computer science students also have trouble coming up with good names!

In my opinion using pinyin is fine. In some ways it will be helpful for new students as they will get a clue of what their code is and what language keywords and 'Base Class Library' functions, etc. are.

You could look and see if there is another programming language, you could use, which supports Unicode characters in variable names.

I know this is possible in C#. See C# identifier naming rules and conventions

Sometimes you may need to start a variable with a Latin printable character for the first 'letter'. Something like an underscore.

$\endgroup$
2
$\begingroup$

You didn't mention what programming language(s) you're working with, but the way PowerShell names things might be helpful here.

Functions have names like Get-Process, Clear-ItemProperty, Write-Host, etc. They're all of the form "verb dash noun". There's a predefined list of verbs that they encourage you to use whenever possible. When naming function parameters, they have predefined lists of common parameter names along with their standard meaning.

PowerShell does this for the sake of consistency, but an approach like this could help a non-native speaker as well. Those lists of words can be augmented with a description in their native language. Naming something consists of selecting the relevant noun and verb from the list (substituting a native language word when needed). Over time, the students will learn the vocabulary and not need the lists any more. Since they're using the same standard words as the built-in system functions, they're also learning how to interpret those functions without needing to look up and translate their documentation.

I'm not necessarily saying that you should teach them using PowerShell (that sounds quite awful, actually). You can follow a similar idea and create a naming convention for whatever language you're using. You'll have to build your own noun/verb lists, but you'll have the opportunity to fine-tune them based on your specific curriculum and assignments.

Standard library functions frequently have cryptic names, but you can create a helper header/library that provides wrappers around the relevant functions using the common naming convention. My CS teacher actually did that for us even though there wasn't a language issue. It helped focus on concepts instead of a specific language's library syntax, simplified many interfaces, and gave the instructor a place to inject helper code that made grading easier or that simulated errors.

You can strip back the layers in a more advanced course, after they're comfortable with the fundamentals.

$\endgroup$
3
1
$\begingroup$

As others say, good naming is hard even for native English speakers.

I don't think there is a straightforward curriculum to follow that makes one good at naming, or a simple criteria against which to measure success.

At the stage of learning programming, when there is still plenty to learn, it might not be important for chosen names to always be great names.

However, I would suggest having regular discussion about the importance of naming, and have examples of good naming schemes for pupils to consider and absorb.

A pre-requisite for naming in English is to be deeply familiar with English. Exposure to a large amount of vocabulary, and examples of existing software naming schemes are also useful.

To become skilled at naming, a person generally has to be interested in language, to some degree for its own sake.

Some others here have also said names don't matter too much in programming. That can be true in limited cases, but as a general statement nothing could be more preposterously false.

$\endgroup$
3
  • $\begingroup$ Good points! As to importance of naming: Naming is about best-practice. Beginning students have a hard time knowing that else goes with if not while (unless you're in Python!), that conditions must be parenthesized (C family) or terminated by ':' (Python). Zillions of such minor points that experienced programmers have struggled understood internalized and forgotten the struggle. $\endgroup$
    – Rushi
    Jun 1, 2023 at 4:50
  • $\begingroup$ In that context a foreign unfamiliar language is a heavy gratuitous burden. In short: naming is fundamental to software engineering. But theres a big gap noob-programming↠ SE. See my pianist-analogy $\endgroup$
    – Rushi
    Jun 1, 2023 at 4:50
  • 1
    $\begingroup$ @Rusi, the "while-else" is an exemplar of dreadful English naming! But yes, even with English itself, there is a process of schooling in which children learn alphabetic symbols and punctuation and all the rest of it. Meanwhile, vocabulary and word choice is largely learned from everyday listening and reading. $\endgroup$
    – Steve
    Jun 1, 2023 at 8:14
1
$\begingroup$

Some simple rules.

  • Design the code to be readable
    • Use the language of the domain: use the business language and natural language of the project. Most languages support unicode. e.g. 火出口 (it says fire exit in very bad Chinese: literally file exile mouth).
    • When naming things consider how they are used, over what they do: Consider what how they will look when used: e.g. if cat.height > 3*meters then direction.set(away from cat), run(fast)

To help with this:

  • Actions should have verb-phrases for names. e.g. run, stop, open.
  • Booleans, and functions returning a boolean should have an adjective-phrase. e.g. is running, is open.
  • Non boolean objects, and functions returning such, should have noun-phrase names. e.g. cat, door, big cat.
  • Sometimes you will need enumerations to pass in to a procedure, these will often be adverbs. e.g. quickly.

Most of this is general advice. However back to the non-English and English speaker. So if they can type their native language, then do that. I cannot think of a language that does not support Unicode names. E.g. these do support it: C, python, rust, scratch, …

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.