October 7th, 2012

Units madness

These days I'm playing with Rana openstreetmap navigation. Even while hacking the kernel, I was wondering why programming languages have so bad support for physical units. In kernel, we have long jiffies, long time_in_msec, long time_in_usec, long time_in_nsec... while I always feld we should have jiffies time, msec_t time, usec_t time, nsec_t time; preferably with compiler support to warn and possibly automatically convert...

But situation in rana is much crazier than that. Data comes from location module. Horizontal speed in km/h, vertical in m/s. Ouch. Then it gets converted to knots... because that's what gpsd uses. Double ouch. Rana was written in U.K. .. so it uses mph. But max speed in openstreetmap is... back in km/h. Triple ouch.