Since people have already complained about
==, let me point out a much worse alternative. PL/I had both
=, but when something was "obviously" an assignment, it would let you get away with using
= to do it. Using
:= let you force something to be an assignment in a situation where the compiler would otherwise interpret it as a comparison.
Unfortunately, the compiler didn't always decided on things quite the way you might expect. Consider just one obvious example:
A = B = 0;
Now, to most people familiar with most "ordinary" languages, the meaning of this is pretty obvious -- assign 0 to both A and B. PL/I is just a bit...different though. For reasons known only to the (insane) designers of the language, the first
= is interpreted as an assignment, but the second
= is interpreted as a comparison. Therefore, this compares B to 0, and then assigns the result of that comparison to A (following the C-style convention that "false" results in 0 and "true" in 1).
So, if B was 0, then A becomes 1. Otherwise, A becomes 0. In other words, rather than assigning the same value to A and B, this actually ensures that A cannot have the same value as B.
Bottom line: even though the C/C++/PHP style initially seems like a pain, the alternative is much worse1.
1Well, technically, there's another alternative: Pascal style, where
= always means comparison and assignment always requires
:=. After using that for a while, it's pretty obvious (at least to me) that assignment is enough more common than comparison that if you're going to require extra "stuff" to disambiguate the two, you should definitely keep assignments clean and simple and require the extra "grunge" on comparisons, not vice versa.