In a quite similar example of a bad convention, I find it extremely frustrating that many programming languages do not have a modulus operator (%) which behaves as modulo in mathematics. To be explicit, there are multiple choices of the sign of:
x % y
When either x or y is negative, or both (the full details are described at Wikipedia: http://en.wikipedia.org/wiki/Modulo_operation). In common mathematical notation x mod y, the result always shares the sign of the divisor y. For example,–14 mod 10 = 6
6 mod –10 = –4
The same is the case in python:
>>> -14 % 10
6
>>> 6 % -10
-4
Unfortunately, in JavaScript (and various other languages), a different convention is chosen. The result instead shares the sign of the dividend: > -14 % 10
-4
> 6 % -10
6
This is really annoying because we quite frequently want to use the modulus operator to do things like normalize an angle to the range [0, 360°). To perform this normalization on an angle a in JavaScript, if a < 0, requires a computation like: a_prime = a % 360 + 360
I end up usually defining a function like: var mod = function (x, y) {
var js_mod;
return (js_mod = x % y) && (x > 0 ^ y > 0) ? js_mod + y : js_mod;
}