Most modern environments actually support working with Unicode. But then to use this in the code has a large space. The first point to consider before thinking about aesthetics and good practice is whether your language supports this. Most define a finite (and small) set of characters from which the source code must be composed. It is usually a subset of ASCII. For example, the C standard says the following (C11, 5.2.1/3):
Both the basic source and basic Execution Character sets Shall have the following
Members: the 26 uppercase Letters of the Latin Alphabet
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
the 26 lowercase Letters of the Latin Alphabet
a b c d e f g h i j k l m
n o p q r s t u v w x y z
the 10 decimal digits
0 1 2 3 4 5 6 7 8 9
the following 29 Graphic characters
! " # % & ' ( ) * + , - . / :
; < = > ? [ \ ] ^ _ { | } ~
Using anything outside of this would be invalid. A compiler can accept, of course. And most accept. But if you want a portable code that will work on any platform, it’s good to restrict.
Another problem is the file encoding. It can happen that two files of the same program are saved with different encodings (for whatever reason). Visually you will see the character É
in both, but at the time of execution, it may be that the compiler/interpreter sees different identifiers there. In the end you will have a rather difficult error to track, since the error message will not help.
One language that widely supports writing code with non-ASCII characters is Ruby. The parser and other tools were built with this in mind and there is no set limiting characters allowed. This makes room for some interesting things, as the article demonstrates Unicode Whitespace Shenigans for Rubyists peter cooper:
Using a Unicode symbol for space (the same as the
of HTML):
(source: in the Gd)
It is not seen as a space, it becomes part of the handle. It allows you to write something as confusing as this:
(source: in the Gd)
Since we have a fullness of space characters to use:
(source: rubyinside.com)
Using Nicode in a codebase makes room for some absurdities and very complicated bugs to track. Another clear problem is trying to copy and paste the code into different tools. You never know what might happen.
Technical problems aside, there is always the question of language (spoken). If it is a large project, or one that becomes opensource, it is always recommended to use English in the code, abolishing the use of Unicode.
In a small project with a team of few developers, there is enough space for rules to be defined and conventions to be created. There being an agreement among all, there is no reason not to. Remembering to always weigh the pros and cons of adopting this style.
A case that I have seen happen and that I consider valid in a certain way is the time to write tests. In many frameworks you define a function/member/method that will be a block of asserts to be executed. When a failure, usually the name of this function is displayed on the screen as the name of the test that failed. Since this is a function you never explicitly call, using placesUnicode in the name can be interesting. Will make the error output much more readable.
I asked this question even to demonstrate how to make something suitable that can give room for breadth and opinions. Programmers also need to learn how to create specifications, whether in programs or questions, negotiate with their peers, defend their arguments, circumvent obstacles without hurting established rules, communicate so that everyone understands. You have to demonstrate real effort and need for the question. Most closed questions could be saved if this was always done. Some third party cases may save, others only OP can do this.
– Maniero
Curious tag,
estilo-de-codificação
, it appears as one of its top 3 tags on this page... Another one that has a curious tag is Math,string
, who the Heck is master string? : D– brasofilo
@brasofilo eu :D http://answall.com/tags/string/topusers I’m about to win medal for her :D
– Maniero
@brasofilo hahahahaha... I’ve thought about it too. Worst q every time I answer a question from String she gets well punctuated. My only two "legal answer" medals are from String :p
– Math