Never write code you don't want to run, part 1
Be careful what you ask a computer to do. Someday it will do it.
When I was a kid, I wanted to go FAST. And my mom, she didn’t care about fast, she only cared about SAFE. And it sucked, and anytime she’s not around I go FAST, and I have a modest basket of broken bones that wouldn’t be so crooked if she could have had any say, but eventually she didn’t have any say and it was worth it. Fast is worth it.
And all of the good programming languages are like my mom. They have at least one construct entirely devoted to “if the bad thing happens, then what?” In the best languages, you say “I will tie my shoelace”, and the language says “But what if you scrape your forehead?” And nothing else can happen until you have an answer.
“I won’t scrape my forehead while I -” UNNNNNHANDLED CASE ScrapeForeheadException WHAT IF YOU SCRAPE YOUR FOREHEAD ON LllllLLLine TWELVE THIRTY THIRTY TWO then what? …
One option is to run away to live with Python, who lets you drink Coke for breakfast and shit in the refrigerator.1 But it would be better to be a goodie two shoes and say “dear mommy I will get a bandaid from the cupboard and put on neosporin”. That might work, or maybe she’ll hit you with a nested DrankTheNeosporinException but then you can say “dear mommy I’ll call poison control” and eventually she’ll be satisfied and your shoes will be tied.2
As you age and better grasp the desperate scarcity of time, you will correctly say “I don’t have time for this” and incorrectly you’ll say “just do nothing”. The thing she’s worried about? It won’t happen. So if it does happen, do nothing. (because it won’t happen)
Fast is worth it. But you would be better off proudly eating your boogers at Python’s house than to “do nothing” if you scrape your forehead. Because while your mom may or may not respect you, your computer absolutely does. If you say “do nothing”, then nothing will be done. Shoelace by shoelace, your foreskull will be ground flat like the lucky red crayon that never got lost, and as you commanded, nothing will be done.
If you scrape your forehead while tying your shoes, you should scream. You should panic, and you should thank the wise mommy who gave you a chance to do so.
self.breakfast(can_of("coke"))
self.tie_shoes()
self.shit_in(self.refrigerator)
> tied shoes
>
>
> dysentery
>
> dysentery
>
>
> dysenterydysenterydysenterydysenterydysentery
try {
tieShoes();
} catch (ScrapeForeheadException e) {
try (Neosporin n = fromCupboard(Neosporin.class)) {
bandaid(n);
} catch (DrankTheNeosporinException e2) {
callPoisonControl(e2);
}
}