Last night my tweet inspired a debate on Twitter about the use of the command line.  Oddly enough I was in a meeting with a customer yesterday and due to some problem I encountered during my demo I had to open the command line.  Once I did this he immediately asked me “Do I need to use the command line?”.  (As a side note the person who asked this question was not a developer or system admin.)   In addition a few weeks ago at MWLUG, Nathan Freeman, who I have the utmost respect for as a person and a developer, stopped me in the middle of my presentation and told me he was completely lost because I was using the Git CLI.  So with so much talk about my use of the command line I figured I would explain why I use it.

It was not long ago that I was not a fan of the command line.  Being a Java developer I lived in Eclipse.  Eclipse did everything for me, it generated code for me, it had type ahead, it would build my code, and I could even run and debug my code….everything I needed in one place.  I knew that I could do all of this outside of Eclipse using various text editors and command line tools, but why would I?  Then one day at work we decided to use an Apache project for one of the projects we were working on.  When I looked at the project documentation they stated they were using Maven to manage the project.  Doing some Googling I found instructions on how to install Maven and realized it was a command line tool, my first thought was “YUK”!  Being an Eclipse lover I immediately Googled to see if there was a plugin for Eclipse and there was, the plugin was called M2Eclipse.  Hallelujah, I could continue to live in Eclipse.  Eventually though I ran into a problem with the Apache project where the Eclipse Maven tools were failing to build the Apache project and I had to use the command line tools.  I bit the bullet and installed the Maven CLI so I could continue to do my work.

Not to long after that I started to use Git.  Again the Git CLI seemed hard for me, I wanted something for Eclipse.  There is a nice Git plugin for Eclipse (or even better something like SourceTree) so again I was able to avoid the command line.  However I noticed something else the more I looked at GitHub projects.  They all said “To get the code run $ git clone”  None of them referenced using an IDE to clone the git repo.  I also noticed some projects taking things one step further tell you to run “git clone” and then run something like “mvn -P run” and that would clone, build, test and deploy code on an embedded web server (not all projects have this functionality).  This is when things started to click for me.  Think about if you wanted to do the same thing with something like Eclipse.  You would have to start Eclipse, clone the git repo, setup a debug configuration to run my maven build, setup a Tomcat server in Eclipse, add the war the maven build produced to your Tomcat configuration, and then start Tomcat from Eclipse.  You could run “mvn -P run” from within Eclipse as well and use the embedded web server from within Eclipse eliminating the need to setup and configure Tomcat but I would argue that you are now eliminating the need for using Eclipse, but it is certainly a valid argument.  If all you want to do is run the application, why go through all the work of using an IDE when you can have the app up and running using the command line by the time your IDE starts?  I have embraced this pattern in my own projects, so much so that I have created projects that can be cloned, built, tested, and deployed to the cloud with 2 commands from the command line.

I can understand those who view the command line as a step backward in simplicity.  You have to remember commands, you can easily screw things up when typing them, installation of command line tools can be a pain, I understand all of this and have been bitten by them many times.  However, the productivity gains you can get are tremendous.  I am not saying the command line is the only option, in fact I don’t exclusively use the command line, there are many times where I still go back into Eclipse.  Recently though I have integrated the command line into my developer toolbox and I have found that it has made me more productive than I was before.  If you are not a command line user today I hope you consider using some command line tools in the future and don’t try and avoid them.  If you spend some time upfront learning the tool I am sure you will find it only makes you a better developer.

Ryan J Baxter

Husband, Father, Software Engineer