Monthly Archives: March 2018

In The Beginning Was The Command Line…

More years ago than I care to admit, a friend of mine loaned me a copy of Neal Stephenson’s In The Beginning Was The Command Line, and miracle of miracles, I’ve finally managed to finish reading it.  (Sorry Chris!)   It really got me thinking about how I use a computer.

It’s a really thought provoking book.  Given it was written in 1999, it was surprising to me, to see how little has changed in one sense in the way that we use our computers. When Stephenson was writing this book, Mac OSx was on the design board, given that Apple had bought out NeXT back then.  Microsoft was still pushing Windows 95, 98 and Windows NT, which as we’re all aware are UI based operating systems.

And he makes the point that the OS software is no longer letting the user interact directly with the computer, but rather it decodes what the user wants to do, and issues the right calls, to make sure that it happens.

I for one am not a fan of that, as a programmer, I want to know EXACTLY what my computer is doing.  (The irony is not lost on me as I type this blog post up in the WordPress desktop application)  And I’m sure I’m not alone in that the first experience of a computer I had didn’t involve a window, but rather a flashing prompt, wating for a command to be entered, or in the case of my ZX Spectrum, a BASIC keyword to be inserted.

And I for one really miss that.  Don’t get me wrong, GUI’s have their purposes, but as Stephenson says in his essay, it puts different layers of abstraction between the user and the hardware on the machine. And it can be both a blessing and a curse.

I code mainly in Linux, and therefore I have a UI editor, which at the moment is Visual Studio Code for my C++/Node.JS stuff, or IntelliJ if I’m doing stuff with Java, but I’ll always, and I do mean always, have a terminal window open.  Because frankly it’s a lot faster for me that trying to find the right option in the UI.  The only reason I use an IDE these days, is that it’s faster to navigate across the project structure, rather than remembering which directory a certain file lives in. So both can live in perfect harmony.

But the command line can also have danger for the uninitated as well.  As I found out to my cost in the early days of using my first PC.  I was in the process of formatting some floppy disks, or at least I was trying to, when I noticed that the drive wasn’t making any noise, but the hard disk light was flashing quite a bit.  I hit control-C, and found that I’d blatted most of my hard disk! (A mighty 40MB back then…)  I thought I’d entered the correct command, but clearly I hadn’t, and so lost about a year’s worth of…..well….accumulated Shareware games…(not a great loss), but I’d also wiped out half of my operating system, which was MS-DOS 4.2.

While there’s dangers in misusing the command line, I also agree with Stephenson that OS companies are doing their users a disservice by hiding commonly used tools in some sub-menu of an application.

He cites the UNIX command wc as an example.  In UNIX, wc gives you the number of words/characters in a file (depending on the arguments you pass it.)  So to get the word count of a file you’d do:

wc -w <filename>

So if I had a file called greeting.txt with the text Hello World in it, the command would return:

emyrw@lothal:~/temp$ wc -w greeting.txt 
2 greeting.txt

Now, if I tried to find that in Word or something like that (although I know there’s a word count on the bottom bar of the application) then you’d need to a) know where to look, or b) know which sub-menu the word count lives.

When I was at university, I wrote my dissertation on an installation of Linux (I think it was Gentoo) and I had a terminal window open, and every time I wanted a word count, I ran the wc command.  For me it was much faster than trying to remember a menu somewhere.

Now I totally get it, not everyone wants to interact with a computer using a command line interface, but I hope that it’s not consigned to history as something old-hat.  (I’ve had someone say that to me once…)  The command line is one of the most useful things to learn to use. If your OS goes bang, then if you know how to navigate around using the command line, and which files to edit, then you have a chance of recovering your system.

If you’ve not read Neal Stephenson’s book, I can’t recommend it enough.