środa, 6 listopada 2013

Imagining program's API

I have to say I'm not exactly a fan of command-line interfaces (CLIs). Graphical UI should be a standard way for almost all applications to communicate with a human being. Eyes are our most-used gate to the world and through it we can process information most quickly. We should take that possibility and design the most simple and elegant, easy to learn and use GUIs.

But what if not an ordinary human, but a computer technical person was the user?

Programmers and power users like to automate things, build larger constructs from smaller blocks and elements that work together. They would want to take a program and use it in some automated and complex task. That's why almost every program should have a command line interface alongside the GUI. Or a blend of both?

The principles of command line interface design should be similar to that of graphical interface. But looks like they are not. The CLIs did not change much in the last two decades of Linux and Windows (the latter did not even improve the almost unusable cmd.exe program over the years). The CLIs are not usually easy to learn and use. Chris Bernard points out some other flaws. However, I do not agree with him on the solution (XML). Because the short names of programs and options are, once you get to learn them, very fast to type and often faster than GUI to get the job done. And they should stay that way.

I think something can be done to improve the overall state of matters while not hurting the typing speed of the command line. In fact, the Windows Powershell brought some significant changes to the thinking about the CLI. Most of all - it is designed around passing of objects instead of text between different programs and commands. It also has a concept of cmdlets that are to offer a bit of categorization to the commands and make them more readable by using prefixes Get- List- etc.

But still, it is far from the usability of managed programming languages. Why can't we simply call a method on a program?

Instead of passing control parameters, the program could be invoked by calling methods and chaining them. Each program would contain a manifest describing its API allowing for method completion and to type just as fast as with short control parameters.

Even Scala and C#, despite being statically typed languages, already got it covered: a console with type and method completion. Of course, programming language is not shell script. The target audience is somewhat different. But the principles of UI design should touch all alike. I think there is a need for a new approach to CLI usability, to make it more readable, faster to learn and more appealing to power users.