This blog is highly personal, makes no attempt at being politically correct, will occasionaly offend your sensibility, and certainly does not represent the opinions of the people I work with or for.
In praise of the command line
avatar

I have a friend who has seen me using my laptop for a while now, who has somehow always been curious of my use of the terminal... Few days ago, I sent an email (reproduced below) to her to explain the command line.


I just want to clarify something about the command line.

Programs on computers manipulate data. Just that. Nothing else. Nothing more. From your web browser to your chat program, to your image manipulation program, to your MP3 player, they all manipulate data.

Now, there are mainly two ways to let a program know which data you want it to manipulate and how you would like it to do it.

One way, which came in second position historically, is the fact of using a Graphical User Interface, which most users confuse with the program itself, and sometimes wrongly call the "OS". ( For instance, once a girl came to me and said "Have you seen the new Android OS on the Galaxy phone ?", I was like "What the hell is she talking about ?, how could she *see* the operating system ?" Later on I understood that she meant "the new updated graphical user interface, with the time displayed here etc..." ).

Graphical user interfaces are now standard on computing devices, because they use metaphors. Little icons that people click on and that trigger specific programmatic actions. The very huge advantage of graphical user interfaces, is that they do not require a learning curve. Anybody become "experts" in their iPads few minutes after having touched them the first time; which is exactly what the iPad makers want.

Another way to interact with a computer is the command line interface, which came first historically. It allows the user to send commands to a program, using a primitive form of written language. This language requires some learning, but then allows the user to specify much more commands in a much more concise and precise way.

For instance, this morning I trimmed and resized a video taken using my phone by issuing :

> ffmpeg -ss 00:03:00 -i 20130802-094735.mp4 -filter:v scale=210:-1 -sws_flags lanczos -strict -2 20130802-094735-2.mp4

picture

- The program I was talking to is called ffmpeg it is a little program that manipulate videos and soundtracks of various formats in lots of powerful ways
- The fragment -ss 00:03:00 specifies that I want the program to skip the first 3 minutes of the original video.
- The fragment -i 20130802-094735.mp4 indicates the name of the original file
- I do not really know what -filter:v does.
- The fragment scale=210:-1 indicated that the movie is to be resized and that the target size is 210 pixels wide and that the ratio must be preserved (so I do not need to specify the target height)
- The fragment -sws_flags lanczos specifies which mathematical algorithm is used for computing the new images.
- The fragment -strict -2 says that it is ok to use some specific codecs.
- The fragment 20130802-094735-2.mp4 gives the name of the file that is created (obviously I want the new file and old files to have different names)

All this would require an enormous amount of clicking and navigation to perform using a graphical user interface.

Moreover, the people who design graphical user interfaces often do not have enough space on the screen to put all the buttons and drop down menus that would allow the users to specify all the things programs can do (as well as all the various subtle ways of doing them). In the end the user cannot use, and in fact doesn't even know about, all the stuff that the expensive program they bought and that they using through the graphical user interface, can actually do. The graphical user interface always let them use just a small subset of that program's capabilities.

Using the command line interface, one can specify an action, the object to be acted upon, and then various attributes required to make the action very specific. This is impossible to achieve using a graphical interface.

Also, modifying a program that has a command line interface is easy, you just modify the core of the program (teaching it to do something new, for instance). Whereas if you are building and maintaining a program with a graphical user interface, you not only have to change the core of the program every time you want to add a new feature, but you also need to make some modifications in the graphical user interface itself, often resulting in annoying your users who "do not like the new way the program looks like..." (and other stupid things...)


[update: 06 August 2013] Here is an example of a very good idea: the Firefox developer toolbar with its command line. I wish that most regular graphical user interfaces had something like that...
[ add a comment ]

Archives