All those things like
Recently, I was trying to find out, what makes people write such code and came to the conclusion that this is either lack of knowledge of statically typed language or mistake or just a fear of legacy code.
Let me explain the latter. There is a code that is stated it is working (possibly for decades). And there is a need to add a feature/fix a bug in that code. After the work is done, there could be changes that result in such code, and the person who does that changes is afraid of moving forward and lefts the comparison as it is.
Note, that this situation is just my imagination, I do not know exactly why such code exists. The situation is based on client’s legacy code, I have to work on. However, that’s not only clients with 10-years old code. Here is the same in Microsoft documentation:
http://msdn.microsoft.com/en-us/library/bb546150.aspx
The example text: