How not to bastardize mathematical notation in a language.

Why are we using == and := for operators in programming languages when we could have used =? and left = alone? This is so much more readable and visually intuitive!
if(a =? b)
while(a =? b)

And we could have unified the notation with >? and <?
if(a <? b)
It is much clearer that we’re asking the computer a question.

I have argued for over a decade that C-derived languages are stupid in many ways. Improved operators such as these would prevent bugs including the age-old problem of programmers accidentally using = for == in a query statement, because =? is more visually distinct, so the programmer cannot accidentally miss it while reading, and they are more likely to remember to use it. This solves the problem better than using := for assignment, since := looks ugly and feels stupid to use, because it doesn’t semantically mean anything on its own. One would only know that it is in fact supposed to be an assignment operator, after someone else explains it. This is typical of engineers to design something poorly and then expect everyone else to memorize what they meant, rather than placing the responsibility on themselves to fit into the existing architecture of a language (mathematical language in this case). Essentially, they are doing the same thing your mother did when she said “Do what I mean, not what I say!” Like, get real. Say what you mean.

In programming languages, it is already customary to use ? to indicate checking a value (such as in the ternary operator), so why hasn’t this been adopted by any well-known language? The most likely culprit is lack of language designer creativity, copying prior art without understanding anything about how it has impacted the practice and products of programming.
Ternary operator (using traditional operator syntax):
return (a == b ? “a equals b” : “a does not equal b”)
This statement returns the first string “a equals b” if a == b, or else the second string.

Leave a Smart Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.