Imagine you want to write a Python program that converts fahrenheit to celsius, but when you run your code, you see that your calculated result for 32 degrees fahrenheit is 25.6 degrees celsius. This isn’t right.
You likely have one of two attitudes. The first is correct, and the second is incorrect (and very common).
- Attitude 1: The computer runs code according to the rules of the programming language you’re using, in this case, Python. You’ve achieved your goal when the program produces correct outputs for all valid inputs.
- Attitude 2: When run, your code causes the computer to produce a myriad of unpredictable results. Programs may achieve your goal, but it’s impossible to know why.
If you have adopted Attitude 1, the mistake in the conversion can be explained by a mistake in your code. If you want to fix the error, you need to find that mistake and correct it.
Attitude 2 is what I refer to as “The Code Happens to Me”. If you have adopted Attitude 2, 25.6 is a bizarre result, and we don’t know why it happened. Maybe running the code again will work? Let’s change a plus sign to a minus, or a division to a multiplication and cross our fingers.
Attitude 2 minimizes your agency as you attempt to create software and is caused by bad explanations of what programming is.
[…]
In programming, the code is the primary independent variable under your control. Without a means of assessing whether a change to that variable has a positive or negative effect, programming will feel at best mysterious, and at worst a useless exercise in the arbitrary arrangement of abstract symbols.