A while ago I was thinking about how to explain what it feels like to do programming to a non-programmer. So, this is what I came up with, and hopefully you’ll find it entertaining.
Essentially, programming is automating things using computer. The greatest power and the greatest weakness of computer is that it does exactly what you told it to, no more, no less. Which means, that on the one hand, it doesn’t get tired, doesn’t lose focus and doesn’t complain. On the other hand, you have to give it very detailed and specific instructions. Because of that even if the task in real life appears to be quite simple and strait forward, programming it can become a bit tricky. Consider an example: let’s say I ask you – a human – to buy groceries for spaghetti carbonara. Now, you probably don’t keep the recipe at the top of your head, so you ask me what products exactly do I need. Then you go to the grocery store and you find out that there’s no spaghetti left, but there’s some linguini, so you buy that instead. And that is a crucial difference between a human and a computer – the ability to make decisions, even if so small. The absence of spaghetti doesn’t make you collapse or hang up, you barely notice it, you quickly adapt to the situation and move on. Now let’s say there is spaghetti, but only a giant pack of 5 kilos. You still buy linguini, because of so called common sense, which boils down to shared context between us. I never specified that 5 kilos was too much, but you and I have a lot of shared knowledge between us, and some of that knowledge allows you to make that decision on your own. That shared context is another important difference.
So let’s take those away and see what happens. I write a script and I know I must be as precise as possible. I specify the brand of bacon and other goods, I specify amounts, the name and address of the store and set it off. And the script blows up because I forgot to mention that you’d need money to pay. Okay, I fix the script and run it again, and it works! The job’s done, I report to my boss that the script is ready for use.
Sometime later the script blows up again. There’s no bacon of this brand left, which made it impossible to buy, which in turn stopped the task from completion. And I’m like “Shit, couldn’t you just buy another one?” but no, there’s no decision making, so I update the script with new instruction: If there’s no bacon of this brand, just buy another brand
. I run the script, it works, and everyone’s happy. The end.
Well, not so. Sometime later I receive “What the fuck? We spent 500 bucks on bacon last month!”. That’s weird. I start digging and eventually find out that for the past several times the script bought “Premium deluxe platinum bacon”, which costs like 10 times more, and it just happened to be the next item on the shelf. So, I put a condition: …buy another bacon for no more than 5 dollars
. I run the script, it works, I report success, everyone’s happy again.
Sometime later, yes, I discover, that my carbonara tastes like shit. I do some digging and the reason is… the script bought the vegan bacon. Of course. I fix that with … no more than 5 dollars and not vegan
, it works again.
Until it doesn’t. The script blew up because the only types of bacon left in this store were vegan, premium deluxe and vegan premium deluxe. You motherfuck. New instruction added: If there’s no bacon, then go to another store and repeat the process
. In fact, let’s make it a standard buying procedure for all the groceries
. It’s a miracle we didn’t have issues with other products so far. I run the script, it works, but at this point I kinda see the pattern and I’m not eager to celebrate.
But it keeps working for a long time, and everyone seemed to relax, until one day my laptop and TV are gone. WHAT. We do intensive digging to find out that I never mentioned in script to lock the door when gone shopping, someone saw the vulnerability and we paid a heavy price. You stupid twat.
Okay, no accidents for quite some time, and then the script blows up again. The store is closed. YOU FUCKWIT, DIDN'T I TELL YOU TO GO TO A DIFFERENT STORE IF THERE'S NO… Oooh, right. If there’s no product at all, go to another store. But not if the store is closed. Yeah, my bad. (Manager: you’re still on that thing? The hell is taking you so long, isn’t it dead simple?) Fixed. If the store is closed, go to another one
. In fact, if there’s any problem with this store, just go to another one
. That’s better.
All right, no issues for a couple of months. But then, yes, you guessed it, something fishy is going on. The script has been gone for groceries for three days now, but never returned, neither reported any error. That’s odd, let’s do some digging. After a long investigation, going back and forth through logs and meditating over the code, we accidentally catch a glimpse of bacon prices. They’ve gone up. Apparently, pandemic hit the farmers pretty hard, which caused the shortage of bacon supply, which also drove the prices 20% up. Which made it a tad more than 5-dollars limit. Which effectively sent our script on an endless loop across all the stores in town. Another day another fix: mark down the stores you went through. If you’ve been at this store on this run before, then stop the shopping and report an error
. Yep. An error, because this requires a human intervention to make a decision based on wider context, and it’s not something a script can handle.
Hopefully, that gives you some idea of what it’s like – trying to foresee and think of everything possible. In reality it’s actually a bit harder, since computer has no concept of bacon, so you have to specify that either name or description of a product contains “bacon”, which one day may result in purchasing a movie with Kevin Bacon starring in it. Because for a computer two brands of bacon are as different as bacon and a pair of shoes. It’s just something you can buy.