“Must we learn command lines…?”

This is an answer to a question originally asked on Quora.com. You can find the original here:
Must we learn command lines (e.g. Make, Bash or -o)?

Must we learn command lines (e.g. Make, Bash or -o)?

Can’t we use a programming or scripting language to create scripts and/or macros? I’m having trouble with Bash commands and I’m lazy trying to figure out how to solve it and was wondering whether learning Bash is worth it.

Answer by Rustin Bergren:

No, you mustn’t. But keep in mind that many things are really just pretty interfaces that convert mouse clicks and field contents in to commands at a lower level that is transparent to you. If you want to understand something well and use it to its fullest potential it’s often best to understand its native language. That said, some things absolutely suck trying to speak to at this fundamental language–which is why Photoshop is way better for doing basic editing on a single image than ImageMagick (note, I say single image).

As far as make, there are plenty of more advanced build environments that totally obscure dependency and conditional compilation details away from you (hide by default really, you can do all and more with them when you dig down) and handle them in the background (somewhat). Xcode for example. But, heaven help you if everything doesn’t always coincidently work the way you expect it to. And if you’ve ever programmed anything, you know how often what you expected to happen doesn’t. Having an intimate knowledge of how things are working underneath makes debugging such things SO much easier. Otherwise when stuff doesn’t work as expected (and I see this all the time) people just takes stabs in the dark as to what the problem is, iterating different possible things, changing this option, that option, restarting, etc. When just a basic knowledge of how the underlying components work together would allow one to systematically check each part, test hypotheses, rule out others and ultimately verify that everything is working as suspected. The compilation tools in Xcode are great and by no means am I attacking them, but having an intimate understanding of what’s going on under the surface is invaluable. To that end, sometimes it’s easier to learn the basics of compilation and build with a much less sophisticated tool like Make.

If you’re interested in being a hacker or system administrator you should definitely learn bash. Especially if you are particularly lazy (like me). That’s right, learning these tools allows you to spend less time doing repetitive boring tasks–that’s the point.

There’s also other benefits to command line type systems, that you will find to like after some time using them.

  • It’s really easy to keep track of what you did to get something to where it is. Often this can be a single screen shot that not only shows the commands you typed, but the results of those commands. A great tool for this is the script command. According to the man-file

    The script utility makes a typescript of everything printed on your terminal…

  • It’s very easy to communicate how to do something in a command line to someone else. Have you ever read a tutorial on how to do something in a gui–scrolling through pictures of mouse clicks? You know what’s worse? Writing a tutorial on how to do something in a gui.
  • It’s easier to script stuff that is fundamentally command-line based. Scripting mouse movements and clicks at horribly tedious. Also, don’t get me started on icons. There’s really just no intuitive way to infer an script line like: “click on the little button that looks like an arrow trying to escape a box…or maybe its an umbrella on a square table…yeah click that and then a new box will magically appear, click the little picture in that box that looks like…”. GUIs sometimes have a scripting interface you can talk to directly (Applescript calls these Scriptable Applications), but these are NEVER any better documented than the gui software itself. And go figure, after tediously writing a manual on how to do stuff in the gui for their application, who wants to write documentation on the scriptable interface no one ever uses anyways. You ask about scripting, theres nothing easier to script than a command line application.
  • Configuration patterns and common tasks, even complicated ones can be very quickly applied. You can just cut and paste them from your “notebook”.

That said, some things absolutely suck when doing them from the command line. But, that’s the answer to a different question.