Hacker News new | ask | show | jobs
by elektrontamer 1284 days ago
> premature optimization

I don't get it. Even when I'm working on a hobby project of no practical value with no deadlines. Premature Optimization is something I'd still like to avoid. I feel like PO harms code maintainability. It's far easier to optimize bottle necks in well written code than do refactor code complicated by PO in my humble opinion.

Edit: Newline

2 comments

Premature optimization should be avoided. It's in the name. But that wasn't really my point.

The problem is that PO is used as a catch-all, low-effort statement to dismiss performance questions and exploration. It's used by devs to antagonize curiosity.

>Premature optimization should be avoided. It's in the name.

Right, the word premature is what makes it a bad thing. What's missing is a complementary concept, let's call it early optimisation. Sometimes you can optimise a thing early on without loss of generality, increase of code complexity (sometimes, with a judicious comment at least, optimised code might even be simpler) or incurring technical debt. The problem is, as there is no awareness of this difference, early optimisation is often misconstrued as premature, even when it really isn't.

I mostly do hobby projects like procedural generation, and I explore stuff I don't understand. As I gain knowledge I refactor and change the code to reflect the new understanding. This new understanding of the problem domain will most often result in performance gain, because the code is much more focused.
I especially love it when people with no knowledge of your code or the systems around it presume to know where the bottlenecks are and tell you to optimize a piece of code nowhere in the vicinity of the critical path. A huge part to optimization is realizing that you have limited time and you want to focus on optimizing the stuff that matters, which means if anyone ever gives you unsolicited advice, they're wrong. Until they've profiled your code, they have no idea where the key optimizations can be found.