It may be that I'm jumping into this conversation a little late, but I
thought some history might be interesting for someone out there:
I think this idiom is a hangover from procedural languages that didn't
support the concept of exceptions. For example, in C,
if (LHS == RHS)
if you inadvertently type
if (LHS = RHS)
then the compiler may not warn you that you attempted to assign a
variable and the bug would be a lot harder to find than tracking down a
NullPointerException.
One way to mitigate this problem would be to have any literal on the
LHS of the expression because then the C (or place favorite procedural
language here) compiler
would complain that you can't assign a value to a literal.
However, in Java throwing a NullPointerException at the exact point
that the code failed is a much better way to find bugs, so letting the
runtime warn you when you pass a null
pointer is less error prone. Besides I hate seeing literals on the RHS
of expressions