For centuries many generations of philosophers were picking arguments against their predecessors or against each other. They were trying to find false assumptions made by others and overthrow the opponent's conclusions or improve on them. Thanks to tremendous work done over all those years, we're capable of critical thinking or even winning an argument by ourselves which wasn't all that common when we look back at human history. Those false assumptions, or errors in logic, are called logical fallacies. A logical fallacy occurs when the premise of someone's argument is true, but the conclusion is false. Today I would like to put a couple of them in a bit different context than a dispute, the one that is very close to all of us. Software development!
I hope that with this little experiment we'll improve on our own critical thinking, learn about a new tool that can be very helpful in almost every aspect of our lives and lastly, maybe prevent a couple of bugs in our code in the future. I've picked three examples that are common and, I think, applicable to software development.
Slippery slope fallacy
It's this kind of argument where one thing might lead to some outcome, and that outcome might cause another thing to happen, and so on, until the final result, which is something so terrifying that you're sure it's better to prevent the initial event from happening. Let me give some real-life example.
This veganism thing is like a sickness! It's spreading everywhere around! Wherever I go, I see a vegan restaurant, vegan cafe, vegan burgers. For crying out loud, VEGAN SHOES! They lost their minds, I'm telling you! What's going to be next?! Vegan law firms, vegan schools? Soon enough there won't be any place serving the beef steak or even a burger! And what after that? We're all going to be doing yoga in yoga pants made out of sugarcane. We'll have to switch to electric cars. I'm sure, there will be a Vegan Police giving out tickets for carrying plastic bags or wearing leather jackets!
I think, when it comes to software development, this kind of false logic usually affects our design decisions.
When building our systems, we always have to decide on tools and technologies which we're going to be using so we're comparing them and benchmarking.
Eventually, we find ourselves in a situation where we have to reject one option. Here is where Slippery Slope fallacy comes in. *It comes out that certain technology requires some new tool. This tool works only in a specific environment so as a result, we need not only to learn how to use this new tool but also to create an environment for it. Since it looks like a lot of work already, we should expect some new problems to appear along the way. Hence we shouldn't consider this technology.
I'm not saying here that we should always pick the solution that seems to have the worst possible outcome, but rather to invest some time and explore other possible results. Sometimes there might be something slipping our attention. Maybe this new tech will benefit us more in the future. Maybe it has some features that can outweigh all its disadvantages. Or maybe we were right to reject it in the first place.
Appeal to consequences fallacy
As humans, we have a tendency of taking for a fact things that we choose to believe in. Appeal to consequences fallacy makes a really good job in clouding our judgment when it comes to telling apart the facts from beliefs. As you might already have guessed it, it's commonly used by politicians to convince us of their ideas.
They come to us with the promise to make the world a better place, and the only way to achieve that is to trust them. And we trust them. We believe in their ideas and the outcome is... well, let's just say that nobody has made the world a perfect place yet.
The general idea behind this fallacy is that since the consequence of something is so much appealing to us, the cause of it must be true.
Exactly like in the politicians' example. We all want to live in a better world and we will, but only when we will trust them. The same logic we can apply to the programming where we always want to achieve some specific result. To put it in some more tangible context I prepared this simple JavaScript snippet that, I think, resembles appeal to consequences fallacy (see Code 1).
Fallacy would be to believe that no matter what our 'fallacy' variable will always be true, no matter what. It might seem this way at the beginning, but when we consider changing the 'antecedent' value to something else like 42 or 'true' (as a word, not a value) it will cause our function to return false because in JavaScript, as in real life, not everything that seems to be true really is true.
For those who don't know, the '!' in JavaScript is negation operator. Negation operator in combination with some value will return only true or false depending on the value. There are 'truthy' and 'falsy' values in JavaScript. 'Truthy' means that they have some actual value like number other than 0 (e.g. 42), a string that is not empty (e.g. ' forty-two'), an object or an array. So when we double negate the 'truthy' value we'll always get true as a result, and that is what 'premise' function is doing. The 'appealToConsequences' function is just checking if 'consequent' variable has the exact value of true. If 'consequent' is true our function assumes that 'antecedent' is also true and gives us information if the assumption is correct. When 'consequent' isn't true function 'appealToConsequences' assumes that 'antecedent' is false and returns the correctness of this assumption as well. Triple equation signs compare two values and return true if they're identical and false if not. Finally, we get our fallacy variable
Appeal to ignorance fallacy
This must be my favorite fallacy, it's so tempting to ignore all the arguments and facts thrown at us and blindly go through life believing in only what we choose to be true. When I think of it I can't help but imagine myself running in circles in a meadow with this big, stupid smile on my face, shouting and singing out loud, not caring about anything. Just me and the meadow, for the rest of my life. If that was a real-life scenario someone might ask, what about food, won't you get hungry? Or what if it rains, or gets cold? For that, my meadow-self would answer 'Not at all, thank you.', and go singing elsewhere. But seriously, appeal to ignorance would be if I said 'I'm not hungry so I don't need any food.', but this example is just a bit extreme, and honestly too abstract. Let's pull our heads from the clouds back to the Earth.
While we're at it, is Earth really spherical or is it a flat surface? I think this question leads right into one of the biggest and most famous appeal-to-ignorance fallacies known to people. Spherical Earth! Just kidding, of course, it is the flat Earth idea. Despite all the evidence some people still believe that the Earth is flat and mostly their argument is the not sufficient counter-argument to their thesis. And that is the essence of the appeal to ignorance fallacy, a belief that statement is false due to lack of evidence of it being true or opposite, a belief that statement is true due to lack of evidence stating it's false. Let's try to put it in some JavaScript words again (see Code 2).
As (I hope) you can see here, this time the fallacy would be the same as previously, to believe that the variable 'fallacy' will always be true. Only now the logic changed a bit. Again, at first, everything looks fine, but let's just change the value of 'antecedent' variable to 0, null or undefined, and our 'appealToIgnorance' function will return false. This happens for the similar reason as in appeal to consequences fallacy case. Not everything that isn't exactly false will cause our 'consequent' variable to be true. There are 'falsy' values that will make 'premise' function to return false. It might be 0, null or undefined along the others. All those values don't carry any real value so they're interpreted as false by double negation we used in the 'premise' function.
Believe it or not, we barely touched on the subject of logical fallacies with those three examples. I picked them out of the initial five selected for this article. If you're interested and want to read more about them there are links to the sources below. I also highly recommend the Philosophize This podcast by Stephen West, he has a fantastic episode about fallacies, explaining a couple of them with very interesting examples.