I program, a lot. And do maths, a lot.
So, why is it that most programming languages still stick with ASCII while virtually all computing platforms now support UNICODE? For example, Python, Javascript and Java (and all its derivatives) all support UNICODE strings as objects you can program with, but it is not possible to use UNICODE as function names or operators.
Tell me, which is visually and conceptually more appealing?:
if((a<=b) && ((x<y) || (b>=a)){ ...
or
if( a≤b ∧ (x<y ∨ b≥a)) {...
In the last example, you immediatly recognise that a≤b ≣ b≥a and write:
if( a≤b ∧ (x<y ∨ a≤b)) {...
And then, by the rule of absorption:
if( x<y ) {...
Okay, may be too simple an example to make an instant convert out of you. But the point I attempt to make is that using the traditional math notation makes it easier to recognise interesting patterns.
There is, however, this small issue of conditionals. The mathematical meaning of ∨ and ∧ is not the same as the operational meaning of && and ||. && is a conditional and and || is a conditional or. Speaking mathematically, it doesn't realy matter, but when using it in a programming language, it does matter.
Granted, we had APL, a programming language in which it was all too easy to abuse the conciseness of its operator syntax into abuse. But there is no objection against a judicious use of, e.g. set operators in, say, SQL or with Python's set operations! I'm willing to wager a bet that as soon as set expressions in programming languages are visually similar to their mathematical counterparts, programmers will be more interested in the mathematical side of sets.
With Mac OS X, the relational operators are very easy to use: <, =, and > are accessible with a Shift-key, ≤, ≥, ≠, ¬ and Ø (which can very well double as an empty set) are accessible with an Alt-key.
To make it easy to use all others which are relevant to you, you can use TextExpander or snippets with TextMate. I bet that you can squeeze this functionality out of your favourite editor on any platform.
Geen opmerkingen:
Een reactie posten