views:

73

answers:

2

JavaScript allows for having unicode escape sequences in identifier names... for example:

var \u0160imeVidas = "blah";

The above variable starts with the (croatian) letter Š, so that the complete name of the variable is "ŠimeVidas". Now, this is neat, but what's the point? Is there any scenario where this feature may be of any use?

-- Šime Vidas http://www.w3viewer.com

+2  A: 

The only use I can think of for using the unicode escape sequence when declaring variables is for obfuscation. You can, of course, type the following for the same variable:

var ŠimeVidas = "blah";

Now, if you were to refer to this variable with a random character in the string replaced with the unicode escape sequence, it would be much more difficult to search for and find those references. Of course, like most other obfuscation technique it would be easily reversible.

If you wanted to use a unicode character that isn't mapped to an Alt+Num combination, it could save time on searching for the key code in charmap (or your OS' equivalent). Not great for saving bytes, though.

Andy E
A: 

Escaping is to allow people of different countries debug the code written by some moronic programmer that thinks it's cool to use non-ASCII chars in identifiers, and allowing non-ASCII chars in identifiers is... well, it's because programming language designers are EVIL.

They are. Really. Didn't you notice? Definitely EVIL.

Have you ever asked yourself why most languages are easy to start coding in and then quite hard to master? That's beacause they want as many low-skilled programmers as possible to keep skilled who-you-gonna-call programmers busy correcting someone else's code, so that new code gets always written by newbies.

BTW You can do that in Java too... it was probably the fad back then :)

giorgiga
so programming skill comes with learning English? -1
Anurag
He was referring to escape sequences in Javascript identifiers, not non-ASCII characters in programming languages in general.
Roy Tinker
Didn't mean to be serious... sorry you took it that bad...
giorgiga
@TimTheTinker Escapes sequences are to be able to convert sources to ASCII (for seamless sharing between systems with different encodings or older SCMs which didn't do a great job with non-ascii files). Allowing the use of non-ASCII chars in the first time is completely pointless IMHO.
giorgiga
@Anurag I was joking about people who use non-ASCII chars in identifiers - whatever language they speak (I'm Italian, but I don't use 'è' in identifiers - nor does anyone I worked with). Anyway, yes, English is part of the skillset of any good programmer (well, maybe academics or people doing very-specific stuff don't need that): how may API docs would you be able to read if you don't know English? how could you read programming forums/articles/blogs? You couldn't even use stackoverflow...
giorgiga