Why code sucks

The reasons people write suboptimal code

My posts of the last three weeks gave an overview of shortcomings in programming by scientists and engineers. Here is a sample:

Why does our code have these shortcomings? I think the reasons can be grouped in three categories:

  1. Lack of knowledge

  2. Lack of discipline

  3. Choice

Programmers also write suboptimal code, and the reason is usually lack of discipline. Sometimes we already know what’s right but fail to apply it. At other times, we don’t have the knowledge, but we know it exists and yet don’t have the discipline to learn. Lack of discipline often has the form of doing something in a quick-and-dirty way although we know we’ll pay for this in the future. In other words, favoring short-term over long-term cost. Of course, sometimes we choose to write bad code—there are valid cases for this.

For non-computer scientists and engineers, I think it’s more complicated. I could write a whole essay hypothesizing what goes on in the mind of a scientist or engineering, but why do this when you can tell me instead? Hit reply and give me you view on the issue!