Cyrus Stoller home about consulting

Code that everyone should know how to write

When people say that they’re learning to code, they usually mean that they’re learning to make websites or mobile apps. Code schools typically teach basic Ruby on Rails and Node.js, aiming to prepare students for junior software development roles. But, if that’s not what you’re aiming for, these crash courses won’t help you.

In general, I think people would benefit more from learning to write simple throw away scripts to automate tasks on their computers. Learning to code shouldn’t just be about becoming a software engineer. It should be about being more technoliterate and about improving productivity.

Novice coders should be encouraged by two observations about these disposable programs. First, even when code is poorly written, the end product is usually the same. Second, I hardly ever need to understand any concepts beyond arrays and dictionaries to write them.

While understanding theory from my CS degree definitely helps me write better software, for simple programs the rate limiting factor is human programming time, not big O notation. In other words, writing slow code doesn’t make a difference. For example, if you use bubble sort when you should have used quick sort for a small data set, the difference in runtime will barely be perceptible.

In the same way that not everyone who knows how to write prose will become a professional author, not everyone who can code will become a professional software developer. Instead of writing programs from first principles, people uninterested in pursuing professional software development should start by learning to use packages, libraries, and frameworks. Small victories and solutions to personal problems will serve as good motivation to keep learning.

Unfortunately, learning to write these disposable scripts can be hard when you don’t know where to start. Because these programs are highly specific to particular tasks, people typically don’t share them on sites like Github.

Getting started

You need to have the right mindset. Anytime you’re asked to perform the same task more than once, ask yourself whether there’s a way to automate it. Here are some examples of the types of scripts you should write.


  1. Reorganizing data: It’s common to need to reorder text. Usually this involves lots of highly error prone copy and paste. Next time, consider writing a script in python or sed.
  2. Standardizing data formats: For example if you want capitalization to be consistent, it’s easy to forget to push shift, but the computer will make sure everything looks the same.
  3. Collecting information: Learn to write web scrapers to extract information from websites.
  4. Downloading datasets from government websites: Usually this take a lot of clicking. Have you computer do it for you.
  5. Renaming files: Instead of clicking each file and renaming it, you can write a simple program to rename all of the files using a consistent naming scheme.
  6. Categorizing data / counting: When there’s a concrete rule for bucketing data, your computer will be far faster and won’t complain about having to redo work.
  7. Removing duplicates: Because computers don’t go cross-eyed, they’re able to find duplicates or near duplicates with ease.
  8. Multiple clicks: If the clicks are predictable, then write a program to execute multiple actions at once.
  9. Analyzing Excel files with complicated logic: Because Excel only allow ten conditional statements in a given cell, running any analysis with complicated logic is nearly impossible. Here’s a simple program I wrote that produces histograms of paths through a network.
  10. Running routine reports: If you need to generate the same report every week based on dynamic data, you should automate that process. By lowering the friction of generating these reports, you’ll make better use of your data.


If you do this, you’ll join the few who use computers as more than glorified typewriters, internet browsers, and television sets. Please email me if you’re interested in having me write up one of these examples. I’m happy to write a follow up.

Thanks to panglott on HN for recommending automate the boring stuff (python).

Category Opinion