Yes, spreadsheets are code. With me? No? Let me explain.
First, let’s talk about my definition of coding. I think coding is the act of writing logical instructions in plain text that can be interpreted by software to do something useful. I take a pretty wide view, admittedly. But I don’t think I’m too far off base.
Let’s break it down. To code, you write logical instructions. These are commands. Sometimes they are called “statements”. Do this. Then do that. For these commands to be “code”, they can’t be subjective. They need to be objective. And they need to make logical sense. They’re not Dalí.
The logic is pretty straightforward, a lot of the time: “show me a new Finder window”. My old friend, AppleScript, can help with this. I love AppleScript.
The instructions need to be in plain text. Don’t be fooled by the bolds and colors — that’s just syntax highlighting. The code is actually plain. The Script Editor just makes it nice looking to make it easier to read, and also to tell you it has “compiled” the code. But no getting ahead of ourselves. Here’s the code:
tell application "Finder" make new Finder window end tell
Ok, so we have a logical (if somewhat dumb) instruction in plain text. Now it needs to be interpreted by software to do something useful. In our little AppleScript case, that means you click the play button icon.
By the way, the play icon has a super cool history. Is audio tape code? No, not plain text…
But what is the play button doing here? It’s interpreting the instructions (code) to do something useful, in this case opening a new Finder window. When you hit the play button, something useful happens. The commands are in text, and they are logical. Ok — that’s code!
What about other things? What about spreadsheets? Ok, slight detour: SQL. Yes, SQL is code.
SQL is a “Structured Query Language” for databases. A query is like a command, but it’s phrased as a question. So SQL asks “how many rows in the users table?” instead of demanding “count the number of rows in the users table”. But same thing, really. It’s a pretty logical instruction. SQL is plain text, and when you send it to the database server (or services), it interprets and does something useful: it gives you the count of rows. So SQL is code.
SELECT COUNT(*) FROM USERS;
This brings us back to spreadsheets. Are spreadsheets code? Let’s see.
Spreadsheets contain formulas that use functions like SUM(). Adding things is pretty logical, so do we have logical instructions? Check.
Are they plain text? Well, yes, in fact some Excel files are based on XML which is a plain text markup language. But setting aside the entire spreadsheet file, let’s think about the stuff in the spreadsheets that performs those logical instructions. Spreadsheet formulas are definitely plain text. Check.
Are spreadsheet formulas interpreted by software to do something useful? Definitely! The spreadsheet software itself is constantly looking at all of the formulas in all of the cells, and trying to immediately interpret them to produce results. Those results are usually pretty useful, like a total amount.
So there you have it. Spreadsheets are code. Congrats, spreadsheet people: you are coders!