June 4, 2013

My Annual Rant

Ok here it is.

I have debugged yesterday a piece of code which i had an older version of, which worked, and a new one which didn't. It took me some time to find out what made the difference:

-2 != -2

There are some crap design jokes in C / C++, but this is really special.
If you apply the unary negation operator on an unsigned int, the result is still an unsigned int. Really, approximately in nearly 100% of all cases not what you want.

The other "highlight" in C / C++, which actually made it verbatim into quite a lot of other languages, e.g. Java, is the totally broken operator precedence hierarchy.

A sane precedence order must account of three distinct groups of operators:
  1. ops which take 2 numbers and yield a numeric result,
  2. ops which take two numbers and yield a boolean result, and 
  3. ops which take 2 boolean values and yield a boolean result.
All operators of group 1 must have higher precedence than those of group 2 and those must have higher precedence than those of group 3. Now take a look at the C / C++ / Java / etc. operator precedence hierarchy and see how broken it is by design.

But that was not the only thing that made me feel bad yesterday. I again ran into the especially good support for gif files in all today's real-world apps.

After i got lately response from some Mozilla cleaning officer, who complained, that the example gifs i made for a 6 year old bug report were no longer available, i now found a well documented, basic and easy feature in gif files which no app i tested did support: pixel size aspect ratio, the ratio of width to height of pixels. I wanted to use pixels with an aspect ratio of 1:2 for screenshots of the TC2048 in 64 column mode. When i displayed them in the OSX image viewer, Xee, Firefox, Chrome or Gimp these looked like double-width scarfs. Only Gimp at least showed a warning. All other ignored the aspect ratio all together. So i had to rewrite my code to produce easier-to-decode images. :-/

sometime these things suck.

No comments:

Post a Comment