If there is truly somewhat abhorred about the use of so many symbols in C, it is the shortcut operators. The use of == gave similar rise to horrific operators such as –, ++, && and || (the latter two need a discussion all their own). Why are they so terrible? – because of the side effects they produce, and their use by novice programmers to produce code which visually “seems” complex – even though they may often not completely understand what they are doing with these operators. Part of the issue may lie with the difficulty in determining what is happening. The ++ operator, for example can be used either before or after an operator: ++a or a++. In a singular statement, both do the same thing. When coupled with other expressions, they act very differently. For example, consider the following code:
b = x * ++a; b = x * a++;
The first expression says “increment a by 1, and then multiply x”. The second expression says “multiply x by a, and then increment a by 1”. But ultimately it leads to people writing code like a++ + b++ or c = a++ + ++b. The use of these operators is problematic only in so much as they can be abused, leading to obfuscated code. Consider the following piece of code:
int a, b; a = 5; b = 7; z = a+++b;
The value of z becomes 12, because the expression is parsed as a++ + b.
Those other, more palatable shortcut operators, like += likely originated from the use of plusab in Algol68, which stood for “plus and becomes”. They aren’t as bad because there is no double meaning attached to them. Legend has it that those horrible shortcut operators evolved due to the need to derive efficient machine code, which makes sense in the low-resource world of early computing. It makes little sense now.
These shortcut operators evolved due to their efficiency in equivalent assembler. Used in the right context, there is nothing intrinsically wrong with them, except maybe for the novice programmer, who may find their use perplexing.