6

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.

  • 3
    can you tell me how to type using my QWERTY keyboard? – Bryan Chen Nov 6 '13 at 4:37
  • 1
    Ever seen an APL keyboard? No? There is a reason non standard keyboards for programming don't take well. – user40980 Nov 6 '13 at 4:44
  • 2
    @BryanChen "alt"+"=" – kyle k Nov 6 '13 at 4:54
  • 1
    not working on my computer... alt+some number does print it, but too hard for me to remember what number – Bryan Chen Nov 6 '13 at 4:57
  • @BryanChen I use a mac, I also etched the symbols onto the keys. – kyle k Nov 6 '13 at 5:03
11

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. – supercat Feb 25 '14 at 0:13
5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.