Tuesday, 27 December 2011

A small example of why programmers can't do UI design

The quiver is a user interface feature in later versions of Angband which allows you to carry multiple stacks of ammunition more easily, without having to dedicate one inventory slot to each different type of ammunition. As a part of this, it automatically assigns a number key to each stack, so you can select the first stack by pressing 0, the second stack by pressing 1 and so on...

Wait a sec.

The first stack by pressing 0?

Well, as it turns out, the quiver was designed by programmers, not UI designers. The problem here is that the character encoding used is ASCII, which assigns character codes for the numeric keys from 0 to 9, not from 1 to 0. So the elegant programming solution is to figure out the character code by subtracting the value for 0 from the actual number typed in to determine which number is used. This 'elegant' solution puts 0 first. Not only that, but for various reasons (e.g. array indexes) programmers are used to counting from 0.

This is despite the fact that every single person involved in the design of the quiver, the various reimplementations across multiple variants, and pretty much every single person who has played using the quiver has the number keys running across the top of their keyboard in the order 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.


Sir Yobgod Ababua the Handless said...

xmodmap and little stickers to the rescue!

Maybe I should sell these "programmer friendly" keyboards that start with 0...

Andrew Doull said...

That reminds me: I need to write a post at some point about internationalisation issues.

Joseph said...

Oh man it's been nearly a decade since I worked with any serious language (C++, Pascal and VB) but I remember distinctly just starting everything at 1. My professors kept pointing out I was wasting a number, wasting space, etc...screw it. KISS.

Artagas said...

They already sell these "programmer firendly" keyboards that start with 0 on the left.
They are called "Hungarian keyboards".
I am using one at the moment.
Not sure about the exact reason for our keyboards being this way, but after reading this post i am pretty sure it has to do with our ancestors being good at (horseback-) archery.