Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I avoid using Unicode characters in variable names? [closed]

The C# language specification says we can use Unicode characters in specifiers (class and variable names, etc.)

I went a long way doing this in my code. Since I live in Brazil, this includes lots of accented characters, with variable names such as rotação, ângulo, máximo, etc.

Every time a more "experienced" developers catches this, I am strongly advised to avoid it and change everything back. Otherwise a lot of kittens will die.

I went then a quite long way undoing it, but today I found some variables still named with accents, in methods written long ago, and no kitten died so far (at least not because of that).

Since my language (Portuguese) is accented, it would make a lot of sense if our codebase has those characters, since C# explicitly allows it.

Are there any sound technical reason not to use Unicode characters in C#/Visual Studio codebases?

like image 464
heltonbiker Avatar asked Jun 27 '14 18:06

heltonbiker


2 Answers

What if you had to take over code written in Cyrillic? Most developers are comfortable with standard Latin character sets. They're easy to type on any keyboard.

I would recommend sticking to the simple set.

like image 137
David Crowell Avatar answered Nov 13 '22 16:11

David Crowell


A few reasons why not to use Unicode variable names:

  1. It makes it hard for people to type them
  2. Some Unicode characters look very similar to non-native speaker (see the case of the Turkish I)
  3. Some editors might not display them correctly
  4. https://twitter.com/Stephan007/status/481001490463866880/photo/1
like image 38
Victor Hurdugaci Avatar answered Nov 13 '22 15:11

Victor Hurdugaci