Please learn to script?

This is a somewhat humorous response to the recent (don't) learn to code debates on Hacker News (arguments against and for). I'm here to advocate a somewhat perpendicular viewpoint, which is that scripting is the thing we should be worrying about, not coding.

Before I say anything further we have to establish a target audience. "Computer skills" is another issue entirely, so let's say that our target users have a basic understanding of how to use a computer: drag-and-drop, some concept of files and folders, how to use a web browser, that kind of thing. Perhaps the user uses a computer regularly for schoolwork but isn't familiar with advanced MS Word commands, whatever. For convenience, I'm going to call this person the "normal" user.

The reason I want to make a trivial terminological distinction here between "coding" and "scripting" is because I want to talk about a specific final goal. My question is: "what's so useful about computers?" For the normal user, a computer is kind of like a third arm, it makes certain things in life easier. For example:

  1. Moving files around on a computer is easier than moving piles of paper around in real life.
  2. Sending email takes less effort than writing a letter, stamping it, and putting it in a mailbox.
  3. Word processing makes it easier to correct mistakes and move paragraphs around than writing on a piece of paper.

But none of this, in my opinion, captures the full potential of computing. In this use case (the computer as a "third arm"), the user still fundamentally has to perform every action. If the user has 10 files they need to rename, the process of renaming each one is quicker--rather than, e.g. using white-out and hand-writing a new label, the user can just type the new name on the computer. But crucially, they still have to do the renaming operation 10 times. If the user had to rename 100 files, they would still have to do the rename operation 100 times. This way of using computers speeds up operations only by a constant factor: what was originally an O(n^2) problem is still an O(n^2) problem.

The thing about coding, or scripting as I will say, is that it gives you the potential for asymptotically better runtimes on your everyday tasks. For example, I have a text file which is a template for a letter, and I want to personalize it for 1000 recipients. This is an O(n) algorithm by hand (e.g. I open it up and write each recipient's name, saving it to the appropriate file), but if I write a script to do it, it's O(1):

for name in recipients:
    with open('template.txt') as templ, open('{}-letter'.format(name)) as f:
        for line in templ:
            f.write(line.format(name))

# template.txt looks like:
# Dear {}, Thank you for your donation to...

This goal, of speeding up things we do by more than a constant factor, is why I want to call it "scripting". The goal is not to produce a program, the goal is to use a computer to do something faster. At least for us college kids, opportunities to do this come up in life surprisingly often. Some examples:

  1. My girlfriend was required for Chemistry class to make a table of properties (chemical, safety, etc.) of certain given compounds. Normally this involves going to a manufacturer's website (Sigma-Aldrich), downloading a PDF, finding the needed information and writing it down. I helped her write a script to automate the process of downloading the PDF and extracting the information.
  2. A class on ecology planted some flowers in hopes of attracting hummingbirds. They left a camcorder to determine if hummingbirds had actually visited the flowers, but someone had to watch the videos afterward and count the hummingbirds. We're trying to write a script right now to detect hummingbird-like motion automatically, so that only the relevant parts of the videos have to be reviewed.

Unfortunately, none of these skills are "sexy", they don't inspire "Ruby on Rails rockstar" attitudes in people. But this sort of pragmatic scripting ability would allow people to actually use their computers to a fuller potential, letting them spend less time mucking about on a computer, and more time living life or doing important things.

Comments

comments powered by Disqus