Right or wrong?
Is writing with left hands wrong? Is typing without touching all 10 fingers wrong? Is not wearing shoes when playing football wrong? Never! It might be weird to you, but it is never wrong.
I believe that there’s no such a clear line of right and wrong in any matter in life. And definitely not in programming.
Right or wrong in programming
Basically computers do not consider right or wrong, or they do not bother with it. Computers are like soldiers who are very obeying and disciplined. We give computer a task to execute, in sequential or parallel, it executes without saying a thing. It knows nothing about right and wrong, it does not care about right or wrong.
When we encounter a problem that needs to be tackled by programming, usually there will be more than one way to code that yields the same desired result. Obviously there will be codes that fast and codes that slow; or codes that “clean” and code that smells (clean and smelly code is another blurred line). We can say bubble sort is slow and inefficient but we can never tell it is wrong. we can say global state is evil but it is never wrong.
In summary, nobody can tell your code is wrong as if the outcome is correct. Definitely not!
Right or wrong in problem solving
Of course, no one is going to hire us as a programmer just because we write clean code or fast code, the ultimate goal they hire us is for the correct code we deliver, for the solutions we bring to solve their problems.
It is absolutely awesome if we can solve the problem in brilliant and nice codes, clap for that. On a bad day one might make a decision that a bunch of people would rant about badly a year later, but as long as it satisfies the desired outcome, the clap still they deserve.
More importantly, a bad solution under a circumstance could be the brilliant solution in other certain circumstances. If I have a list of 100 numbers to sort, that’s an one-off task and has nothing to do with speed or efficiency, I will definitely go for Bubble Sort, because it is so easy to implement and does the job.
Millions of problems are created everyday, each of them evolves and produces their own children. Therefore every solution is really contextual and tackles its specific problem. It would be extremely unfair if you judge a solution under other scenarios with different conditions. If you watched Silicon Valley TV show, there was a scene when Peter Gregory decided to terminate the Internet 2.0 project, he did not expect the global explosion of smart phones and predicted the “Weissman Score” could never exceed the record of
2.89 which Richard Hendricks would afterwards deeply broke in the Techcrunch conference. So could we human beings judge that Gregory’s decision/solution wrong? Absolutely not, because it was the best solution at the moment.
The best solution is not necessarily always the fastest, finest or most efficient. Aforementioned it is contingent upon the context, the conditions and the knowledge of the solvers. If we have given our best shot, there is nothing to regret about. And next time we are trying to judge something, be more fair, considerate and more wide-sighted.