Are there any programming languages that support the use of unicode logic operators? For example, many programming languages use "!=" as the "does not equal"
operator, but in mathematics the symbol is "≠".
Since unicode is now more standardized, why don't programming languages support their use as logical operators? Many of the symbols are on my keyboard, I just hit the alt
button.
2 Answers
Yes some languages do. Why not more? Probably because it's a pain to type. I use all the languages I linked above and I rarely use unicode syntax, it's not on my keyboard and it adds about 0 value to my code.
I'm also aware of the fact that unicode is standardized, but not always implemented well. Emacs had problems with it until quite recently, many languages still are bad at unicode which makes it a pain to parse/autogenerate.
That being said, when I do any literate programming or typeset code in anyway, I do use unicode, but there it's with a simple script to do textual substitutions.
-
I wonder why Windows doesn't provide any decent way to type non-ASCII characters on its US keyboard layout? The Macintosh could easily type the arithmetic operators back in the 1980's, as could by DOS-based text editor.– supercatFeb 25, 2014 at 0:13
Julia uses unicode extensively. It allows you to define both operators and variables using unicode symbols.
The best way I found to input the chars is to use the "latex-completions" plugin for Atom, which allows you to replace, for example "\alpha" with "α" just by pressing tab.
I guess since Julia is more oriented towards scientific computing having greek variable names is a big plus for readability (compare gradient_delta with ∇δ). Also, ≠ is slightly better than != or not (=) when you get used to it.
Anyway, at first freely using unicode chars in code seemed quite odd, and I was afraid things would break. Living in a spanish-speaking country I learned to hate programmers who would input accented vowels (á,é,í,ó,ú) in code comments, because it usually wreaks havoc with tools that only support strict ascii. But I must say that in Julia (also in Latex with xetex or unicode support packages) it works perfectly.
≠
using my QWERTY keyboard?"alt"
+"="
alt
+some number does print it, but too hard for me to remember what number