JnBrymn
JnBrymn

Reputation: 25353

Unicode based programming language

This is a curiosity more than anything: Does there exist a programming language that allows variables, functions, and classes to be named using using Unicode rather than ASCII (except, of course, for special characters such as '+')? Do any popular languages have support for this?

Also, related to this, if any common language supports Unicode, then is there any way to convert an existing API into a language of the user's own choice? It seems like it would be helpful to give a programmer the ability to learn an API in their own language. I imagine downloading a standard API (for instance boost) and then downloading the standard translation mapping and then being able to program in my native language.

Upvotes: 14

Views: 5155

Answers (13)

Ram
Ram

Reputation: 21

Consider Swift, introduced by Apple in 2014. Here is a code snippet:

var 国 = "美国"

Good Luck with your search for the best one!

Upvotes: 2

Oded
Oded

Reputation: 498914

As you can see from other answers, most modern languages allow this, including Perl, Python, Go, Ruby, Java, C♯, variants of lisp, Fortess, ADA, and many more. C and C++ do not, but those aren’t modern.

Regarding C♯, from MSDN:

The rules for identifiers given in this section correspond exactly to those recommended by the Unicode Standard Annex 15


As for converting an API to a chosen language - this is not feasible. You would require a translator that understands the nuances and meaning of every method, variable and class name and translate those correctly - this is not the same as being able to use the characters of a chosen language in code.

Upvotes: 9

tchrist
tchrist

Reputation: 80384

Perl and Go both allow full Unicode identifiers. Perl requires a use utf8; declaration, but Go does this automatically.

See UAX#31: Unicode Identifier and Pattern Syntax, for various concerns.

In general, an identifier should match the pattern ^\p{ID_Start}\p{ID_Continue}*$, although languages are free to add to that. For example, Java adds the currency symbols (\p{Sc}), including $.

Upvotes: 0

I GIVE TERRIBLE ADVICE
I GIVE TERRIBLE ADVICE

Reputation: 9648

Scheme, PLT Racket and Lisp Flavored Erlang all allow for unicode identifiers (made simple thanks to prefix syntax)

Upvotes: 1

Francis Niu
Francis Niu

Reputation: 632

C#, Java, Python3, as far as I know, are all Unicode based programming.

I found no one above mentioned Python, so I added it. Python has a fantasy feature: everything (function, class, module, variable, class instance) is object and every object can attached a document to describe it. This feature may be useful for organizing code and executing script interactively. For example:

# Python code in interactive mode
>>> def MyFunc():
    '''This is self-included document.
It can be write in multi lines.'''
    print('foobar')
>>> print(MyFunc.__doc__)
This is self-included document.
It can be write in multi lines.
>>> MyFunc()
foobar

Upvotes: 2

Nasser Hadjloo
Nasser Hadjloo

Reputation: 12610

.Net supports Unicode and I'm working with C# Unicode variable everyday.

Upvotes: 2

Ðаn
Ðаn

Reputation: 10875

Fortress makes extensive use of Unicode (perhaps in an APL-like way); see http://projectfortress.sun.com/Projects/Community/wiki/FeatherweightJava for one example.

Upvotes: 2

Donal Fellows
Donal Fellows

Reputation: 137557

Tcl allows you to use Unicode characters for command and variable names, though it's recommended to avoid them for variable names because the shortcut syntax doesn't cope at the moment (i.e., you'd have to use the form [set Ω] instead of ).

Upvotes: 1

some
some

Reputation: 49582

Javascript has this feature.

Upvotes: 2

coding Bott
coding Bott

Reputation: 4357

Delphi has that feature since Version 2009

Upvotes: 2

John
John

Reputation: 120

Some implementations of common lisp would allow this. AFAIK the language specification doesn't forbid it or require it (it only requires a basic ASCII character set).

Upvotes: 1

Johan Kotlinski
Johan Kotlinski

Reputation: 25729

Java has this feature.

Upvotes: 1

Ondrej Tucny
Ondrej Tucny

Reputation: 27962

Ada (among others) allows for internationalized identifiers using UNICODE.

However, my personal opinion is software should be written using a single, universally understandable and sufficiently simple language (English, obviously) to encourage collaboration, ensure understandability and reusability of code.

Upvotes: 3

Related Questions