August 22, 2012

What Is A Right Answer?

I find that modern culture is often obsessed with a concept of wrongness. It is a tendency to paint things in a black and white fashion, as if there are simply wrong answers and right answers and nothing in-between. While I have seen this in every single imaginable discipline (including art and music, which is particularly disturbing), it is most obvious to me in the realm of programming.

When people aren't making astonishingly over-generalized statements like trying to say one programming language is better than another without context, we often try to find the "best" way to do something. The problem is that we don't often bother to think about exactly what makes the best answer the best answer. Does it have to be fast? If speed was the only thing that was important, we'd write everything in assembly. Does it have to be simple? I could list a thousand instances were simplicity fails to account for edge-cases that render the code useless. Does it have to be easy to understand? If you want something to be easy to understand, then the entire C standard library is one giant wrong answer that's being relied upon by virtually every single program in the entire world.

For a concept taken for granted by most programmers, defining what exactly makes an implementation "optimal" is incredibly difficult. A frightening number of programmers are also incapable of realizing this, and continue to hang on to basic assumptions that one would think should hold everywhere, when very few of them actually do. Things like "the program should not crash" seem reasonable, but what if you want to ensure that a safety feature crashed the program instead of corrupting the system?

The knee-jerk reaction to this is "Oh yeah, except for that." This phrase seems to underlie many of the schisms in the programming community. Virtually every single assumption that could be held by a programmer will be wrong somewhere. I regularly encounter programmers who think you should do something a specific way no matter what, until you ask them about making a kernel. "Oh yeah, except for that." Or a sound processing library. "Oh yeah, except for that." Or a rover on mars. Or a video decoder. Or a raytracer. Or a driver. Or a compiler. Or a robot. Or scientific computing.

All these except-for-that's betray the fundamental failure of modern programming culture: There is no right answer. The entire concept of Right and Wrong does not belong in programming, because you are trying to find your way to a solution and there are billions of ways to get there, and the one that works best for your particular situation depends on hundreds of thousands of independent variables. Yet, there is a "right answer" on Stack Overflow. There are books on writing "proper code". There are "best practices". People talk about programming solutions that are "more right" than others. There are black and white, right and wrong, yes or no questions pervading the consciousness of the majority of programmers, who foolishly think that you can actually reduce an engineering problem into a mathematical one, despite overwhelming evidence that you simply cannot escape the clutches of reality and how long it takes an electron to reach the other side of a silicon wafer.

If you ask someone how to do something the right way, you are asking the wrong question. You should be asking them how to solve your problem. You didn't do something the wrong way, you simply solved the wrong problem.


  1. Well, what about in life? I find this dissertation parallel to many of life's precarious situations. Most of the time, I think the concept of right and wrong is a means to an end. It is a gross method of oversimplification in order for people to justify coming to conclusions to things they do not readily understand. In a way, static "rights" and "wrongs" do not belong in life, because it leaves open the door for individual interpretation. What may be considered right and just by one person will most assuredly be considered cruel and wrong by another.

    In any other case, it's nothing more than an ego boost. One wants to see himself as right, impeccable, and infallible when in reality one is never any of these things. And even when one commits to wrongs, he will most assuredly have an excuse readily available pertaining as to why he did wrong instead of right.

    The bottom line -- there is no black and white, only varying shades of grey.

    1. It sometimes surprises me how many people rail against facing the truth - Nothing is ever simple. Shades of grey are all we have.

  2. My working theory on this is that there is a large subset of people who believe deep down that things are fundamentally fixable. If something is not fixable it creates an uncomfortable feeling they have to resolve. They latch onto ideas as solutions because they can't accept there being no true solution.

    Telling such a person there is no perfect optimum won't resolve the issue. It will just make them angry because you're damaging their happiness. Their brain is disagreeing with reality at a basic level and you just can't fix that (baring hitting them on the head really hard). When life does shatter one of their illusions, they will generally just switch to a new belief.

    1. The strange thing about this is that I believe that everything is fixable, but I do not believe that there is going to be any particular optimal solution. In my case, society in general is just so completely broken that it isn't very hard to make things significantly better while still being light-years away from any "optimal" answer, and there are many different ways of doing so.

      I do agree that it seems to be a fundamental simplification that people desperately hang on to regardless of reality, though. It seems closely related to religion in that regard.