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
- Python identifiers lexical structure
- The Python Design Document
- General Python Unicode Howto
- The mailing list discussion (started by a French-Japanese-English trilingual)
- Unicode letter categories — not Python specific
- Unicode categories and CJK ideograph complications
- My own thoughts on programming using unicode — can be whimsical!