I was teach on mathematics that on real line small numbers are on left and big numbers are on right. Therefore, I think the comparison 0<1 is more natural than 1>0, and in general, x less than y is easier to read than y greater than x. Is there any statistics if there are less bugs on programs that uses only less than comparisons than programs uses greater than comparisons or both?
I think the typical order has more to do with grammatical conventions actually.
Joe is heavier than Bob
Joe is the subject, the one we're talking about; Bob is just an object we compare against.
Joe weighs more than 90kg
90kg is less than Joe weighs
The second one is a very odd sentence.
[subject] [verb] [object]
[variable] [operator] [constant]
This would be a pretty normal construction, such as:
x < 0
x > 0
but odd would be:
0 < x
Because the value of 0 isn't changing. Zero is not the "subject" of what we're doing.
x is the subject, the variable, the interesting thing.
So what if we're comparing two variables?
x < y
It's possible both of these are new values to us, but intuitively, this code feels like it's more about
x than about
if x < y: do something if x > z: do something
x is our main subject, running against various other variables to see if something needs to be done.
So, my impression is that any preference for
> or otherwise pales in comparison for the preference to put the "subject" of the comparison on the left.
First, I doubt that there are any such statistics because the effect would seem to be so small as to be overwhelmed by other, more common, things. You could, perhaps, create an instrument (as in a compiler) to look for such things and look for effects in, say, unit tests of the code. But that implies that a lot of things come together.
But, I would also suggest that your basic understanding of human psychology may be naive. It could well be that there are people who actually think more effectively in "greater than" mode. As a mathematician, I've often been confused by left-right and by east-west, especially when they all show up in the same context. But it is, I'm pretty sure, because, I look at things with a "frameless" view. What is left and what is right depends on where I think of myself as viewing from.
Also, some times it is just more "natural" to express things with greater than, as in "error > 0.05".
So, I think a teaching "rubric" that punished students for using one form over the other would be misplaced. It would, in some situations, lead the user to perform an extra step in their thinking, and that, alone, could lead to an error.
Similar to Buffy, I suspect that which use is more natural depends on the framing of the problem.
while (countdown > 0)
makes perfect sense. By contrast,
while (0 < countdown)
feels less intuitive, if only because there is a bias towards leaving the variable on the left side of an expression.
I think that the key (and this is what I would communicate to my students) is to make whatever choices you make carefully reflect the mental model of the problem. This should create the clearest code, and produce the fewest errors.