CLIs are reified UIs

Jul 02, 2017 — Tags: Musings

In this article we’ll shine a new light on the age old debate about the advantages of CLIs vs. GUIs: Many of the advantages of Command Line Interfaces can be attributed to the fact that they reify the user interaction: the interaction itself is made into something that’s visible and can be interacted with.

First, some definitions: Two main paradigms of interaction between humans and computers are Command Line Interfaces (CLIs) and Graphical User Interfaces (GUIs). In CLIs the user interacts with the computer by sequentially typing various textual commands, to which the computer replies, also in text. Graphical interfaces base the interaction with the computer on graphical icons and widgets and navigation typically depends on a pointing device such as the mouse. The debate on the respective advantages and disadvantages of these paradigms stretches back decades.

Proponents of GUIs typically stress their ease of use, especially for non-experts. A key contributer to GUIs ease of use is discoverability: at any time the various available options are laid out on the screen and can be further explored with the mouse.

CLIs predate GUIs. Despite of the ease of use of the latter, usage of CLIs persists, especially in UNIX-like systems. This has come as a surprise to some. Typically offered explanations are:

  • Power of the keyboard — the keyboard allows for faster input than the alternation of keyboard & mouse usage.
  • Reproducability - because all commands are text, they may be more easily reproduced and shared.
  • Composable commands — commands on the command line may be arbitrarily composed, using the output of one command as the input of another. This allows for powerful means of expression.
  • Scripting — the interactive session may be used as the basis for a script (a computer program), allowing for the automation of certain tasks.

Rather than rehashing old debates, I’ll try to present a somewhat new perspective on the matter. I’ll do so by examining the CLI through the lens of the present project, Expressions of Change.

Reification of Interaction

Let’s start by stating the obvious: In a command-line interface the textual commands are displayed on screen as typed. The output of each command is displayed below it. Previously entered commands and outputs are scrolled up as required, i.e. when the screen is full.

This means that the human-computer interaction is being expressed in a tangible and visible way. This can be said for both individual parts of the interaction (individual commands) and for the interaction as a whole (the history of an entire session).

A more fancy way to say this is: the user-computer interaction is reified.

Note how this contrasts with the typical interaction in a GUI: There, after clicking on some button or icon, the GUI will respond in some way, e.g. by opening a new screen or copying a file. However, the action of clicking the button itself can no longer be observed, manipulated or shared after it has happened.1

In CLIs, as mentioned above, the commands as given and their outputs are displayed on screen. In typical setups the support for reification is a bit more powerful than that:

  • Keyboard shortcuts — several keyboard shortcuts allow for usage of past commands, e.g. arrow-up typically shows the previously issued command, and CTRL+R typically opens a search prompt which allows for searching previously issued commands. Previous commands are not just visible on screen, but can be selected with minimal effort.

  • Copy/paste — support for copy/paste makes it so that arbitrary text from the screen may be copied, and that text from arbitrary sources (including the screen itself) may be pasted as a new command. Note the symmetry between the input and output formats: everything is text. This allows for the copying of an entire session’s output into the documentation, an internet forum or script. Conversely, solutions from internet forums may be copied into the session without friction.

  • Persistent history — the full history of commands is written to a file, which can include the date and time they were issued.2 This allows for the answering of questions such as:

    • “How did I use this command last time I used it?”
    • “Which packages have been installed on this system?”
    • “I thought I already solved this yesterday, am I losing my mind?”

The relationship with the project that this site is about, Expressions of Change, is quite simple. The commands, or at least some of them, affect the system, and are thus the changes. The fact that they are reified is simply another way of saying that commands are available as a first level citizens. We can see them, copy them, and even generate them using other commands. In other words: reification of interaction as in CLIs is an actually existing and quite popular example of an expression of change!

As an aside: A number of the often cited advantages of CLIs might be interpreted simply as natural consequences of the reification: looking at the list of advantages from the introduction of the article, we see that both reproducability across sessions and the ability to take an interactive session as the basis for a script are simply direct consequences of the reification.

GUIs

The above is not to be taken as an argument that CLIs are a fundamentally better paradigm of user-computer interaction than GUIs. The point is rather that reification of interaction is extremely valuable, and that it is worthwhile to consider how to include it in any interface, even a GUI.

There is, after all, no fundamental reason a GUI could not be designed with the goal of reification of interaction in mind; it’s just that it is rarely done in practice.

The main way in which reification of interaction shows up in GUIs is through the undo command. Unfortunately this is often implemented in ways that are much less generally applicable than those we’ve seen of CLIs.

Limits to the reification

Having established that CLIs reify the user-computer interaction to some degree, it is interesting to consider some typically applying practical limitations.

As mentioned above, the commands as given by the user are stored in a sequential history. One standard for history-keeping is the following: If we start with a clean system, and replay all the commands from the history, will we end up with the same system? This is a way of measuring how much of the relationship between the past and the present is actually captured by the history.

For CLIs in the UNIX-like world, the answer to the question is “we will typically not end up with the same system”. There are a number of reasons for this:

  • The history is not properly organized. The commands may interact with one another via their “environment”, but the relevant information to reproduce the interactions is not stored. For example, the cd command may change the working directory; consecutive commands should then be interpreted as being executed from that directory. However, the history does not reflect the closing of sessions or the creation of new ones, so we cannot say about a command from which directory it was executed.

  • The history is incomplete. Your interaction with the system as a whole is not restricted to the interaction via the CLI but will typically include interaction with arbitray applicationsand the meaning of the commands themselves is not constricted in any way. We cannot make any statement about how these arbitrary commands and applications affect the system with certainty.

Out of these limitations other follow. For example: the undo-command is not available in CLIs, because it would imply some constraint on the available commands (namely: commands should be limited to those that can be undone).

Conclusion

A unique advantage that Command Line Interfaces typically offer over Graphical User Interfaces is that the interaction between user and computer is reified: it is made visible, and the user can directly interact with it, for example by copy/pasting commands.

Many of the typically cited advantages of the command line are simply a consequence of this important fact.

The reification of interaction is, however, not fundamentally limited to CLIs, and the concept may just as well be applied to GUIs.

We have also seen a number of typical limitations to the reification of interaction as typically available in the CLIs of UNIX-like systems; such limitations are not fundamental to the reification, but are a consequence of the reification being accidental rather than being an explicit design goal in the design of the UNIX.

  1. Tools to record interactions with GUIs do exist, but they are significantly less useful and robust than their (built-in) counterpart in CLIs. 

  2. Making sure the saved history has (virtually — from the human perspective) unlimited length and saving the timestamps typically requires some configuration.