Usability is a hot topic on KDEland. Almost everyone who reads this will have seen, one time or another, articles with titles like What Linux Needs To Win On The Desktop Wars or some other similar nonsense.
I say nonsense because there is no war, and if article writers are so clever they would be actually writing software that could win such war. And that includes me. Hell, I am not that much of an article writer, (or that much of a programmer, for that matter).
However, I know this: code beats words. Thinking beats not thinking. Often, to think right, you have to start from nothing.
So, I started thinking... what is the worse possible program in all of KDE, usability-wise? And the answer is prettty obvious. The calculator. And what can I do about it? Write a calculator that makes at least some sense.
But wait, you may say, the calculator? Who uses that thing? Probably noone, because it´s a program that makes no sense. It´s a clone of a program that made no sense in the first place.
How wrong is the calculator? Let me count the ways...
Q: Why so many buttons?
A: Those are the calculator buttons
Q: What happens when I press the 1 button?
A: It inputs the number 1 into the calculator.
Q: Oh, cool. But why not use the nice, 3D button made of plastic with the number 1 I have in my keyboard?
A: You can use that button
Q: So why is the button on the screen?
A: It serves no useful purpose whatsoever.
Yes, the calculator´s most obvious mode of operation (clicking on the widgets) means you use your mouse and pointer to emulate a finger, clicking on emulated calculator buttons. Oh, sure, the emulated finger is 10x slower and 20x less accurate than your actual finger clicking actual keys, but hey, it makes it look like a calculator! Which reminds me...
It´s usually accepted that a toolbar with 20 items has at least 8 too many. The kcalc window shows 33. In the simple mode. On the others it shows many more. You just shouldn´t put 30+ buttons in a window unless you have a very good reason. But that´ s not the real problem. The real problem is...
You can see a MR button. And a M+ one. And several others. If you haven´ t ever learned what those do, they are the interface to the calculator´s memory stack.
That is very useful in a calculator, because it means you can do things you usally can´ t, like 2*(3+3).
Let me quote the KCalc handbook on the subject:
Yup. It´s not even documented. Because you are supposed to know how to do it from using a real calculator, I suppose. So, for 90% of the users, those buttons are just decoration. MInd you, this is not a criticism of the doc writers. A good reason not to document it is that it´s a useless feature and their time is limited.
We are using, to emulate this 1960s piece of hardware, a freaking computer. You know, a calculator usually has about 1024 memory locations. Your computer has probably over 128 millions. And drawing one of those cute buttons uses a couple thousands of them.
In fact, let´s try something more radical: your computer´s keyboard has parentheses in it. You know, these? () ? Those are used to group operations. So you don´ t have to use a calculator-like memory. And you can tell your computer to remember things. Hell, you can tell your computer to reemmber everything.
Ever seen a ticket-tape calculator? Those are rather more expensive than the simple LCD-type stuff kcalc emulates. They have a roll of paper, and whatever you do, it prints. That way, you can later check what your previous operations were, and what their result was. Usually, you are limited somewhat because it uses paper. But we have a computer with millions of bytes of memory. We can have a practically infinite tape.
So, kcalc is not only emulating a calculator when it doesn´t have to, but it also is emulating the wrong one.
Here you can find Usecalc. I wrote it in 20 minutes. It´s a much nicer calculator. It uses PyQt, so you need that if you want to try it, but even if you don´t, look at the screenshot.
The thing that jumps up at you is, of course, that it doesn´t look like a calculator. Remember, that´s good.
Here´s the manual:
- Type what you want calculated on the bottom.
- Results and errors come up at the top scroller.
- You can get back anything from the scroller by double-clicking in it.
- The supported operators are the usual, plus parenthesis, and ** which is power. If you want a square root, just use **0.5. If you want, I can add something more obvious.
- Lots of other things work, since you can use (some) python code in it.
And that´s that.
I dare anyone say this calculator is not more usable than kcalc ;-)
Sure, anyone can take kcalc and use it right away. But if you want to actually use a calculator, UseCalc is a bazillion times better, IMHO.
- It uses python´s eval() so it´s probably unsafe as hell.
- I am not sure the right-justification for results and errors is a good idea.
- If you want floating point, you have to use floating point. For example: 5/2=2 but 5/2.=2.5
- There´s something wrong with the width of the QListViewItems. Try 2**500 with a small window and see.
- Such a simple tool should really be written in C++ so it starts quicker.
- I wrote it in 20 minutes (15 to get the QListViewItems to draw themselves fancy). So it´s really just a hack I don´t intend to maintain.
What can we learn from this? Well, I don´ t know about you, but I learnt that Usability sometimes means throwing away stuff. And that sometimes replacing something with a better version can actually be simple. Usecalc´s code is about 1/100th of kcalc´s (just guessing, Usecalc is 100 lines of non-generated code). A real version would probably stil be 1/10th the size.
I also learned that calculators are easy to write, if you drop all the baggage ;-)
(Ok, so I cheated, I used Python ;-)