Why premature optimisation won’t save you from failure

Aditya Darekar
3 min readJun 14, 2021

--

The Final Project: Please don’t judge the GUI, it could do a lot of useful stuff. Also, I was just 17.

2018: When I was working on my 12th Grade CS Project, I was unaware of this term called ‘Premature Optimization’ but I was damn sure of what I was doing with that 1000 line program I had written. I would write each function carefully, then try to run and test it to see if it worked correctly because syntax errors and run-time errors hurt programmers a lot (both mentally and emotionally). So I wanted it to be as perfect as possible. I didn’t find the guts to write more than 50 lines of code without saving and compiling the code, periodically. As a result, a 1–2 month project took about 5 months of the last semester of my final (and most important) school year. I was so determined (and terrible at multi-tasking) that I even went on skipping study/revision routines for the other subjects to complete the project.

So basically, Premature Optimization is a word mostly used in the Coder’s or Programmer’s World, in which a coder takes extra care to optimize his code to make it run more efficiently. So extra is this care that we have no option but to call it, premature and thus the name.

But, Premature Optimization is a mental model people across many fields have adopted over time so that it no longer speaks only for a Programmer. Let us take the example of, say, a Chef. A rookie chef at his new job decides to taste his dish whenever he adds a new ingredient, to make sure it has blended well. Do you see any shortcomings there? No harm, right? You might find the final dish to be one of the most perfect and delicious cuisine out there! Special Praises to the rookie Chef!

No harm until the Chef or the 2018 Programmer, Me decide to introspect.

And here’s the final result: Spending too much time perfecting my project code, made my project ultimately perfect! My professor might have been so happy if he knew how many night’s sleep I had sacrificed. Or a better way of measuring — How many subjects study/revision routines I had skipped to get the final CS project right. In the case of the Chef, he would have similarly sacrificed the time for other cuisines to make this one perfect. As a result, other customers at the restaurant received their orders, possibly late. What’s your take on the Chef now? Rookie, he is.

I am no expert at this subject but I feel many start-ups make similar mistakes. Optimizing their products too early before getting any customer reviews. Or sometimes, optimising it for so long that the product no longer remains relevant. You have to take into account external factors like these too. Remember, to set a deadline even for the optimisation.

In short, premature optimisation always comes at the cost of something else. And sometimes it is just, worrying about the wrong stuff at the wrong time! Not to say that this mental model is completely ridiculous or useless. If you have enough time to devote to a task and wish to perfect it, premature optimization is something to always remember then. But if you have other tasks on the mind or you are just simply too anxious like me to test it, you better reconsider premature optimization. This mental model could easily turn into a potential fallacy.

Post Takeaway: Before running the ‘Premature Optimization’ mental model, it is essential to consider how necessary it is for the given task and at what cost(sacrifices) are you running it. A few external factors are also to be considered.

--

--

Aditya Darekar

23 | IT Graduate | Tech Enthusiast | Digital Artist | Bibliophile | Love to write what I read 📚and watch 📺