9

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.

8
  • 3
    can you tell me how to type using my QWERTY keyboard?
    – Bryan Chen
    Nov 6, 2013 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, 2013 at 4:44
  • 2
    @BryanChen "alt"+"="
    – kyle k
    Nov 6, 2013 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, 2013 at 4:57
  • @BryanChen I use a mac, I also etched the symbols onto the keys.
    – kyle k
    Nov 6, 2013 at 5:03

2 Answers 2

14

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.

1
  • 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, 2014 at 0:13
7

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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