News for hackers. Stuff that matters.
Re:The 'premature optimization is evil' myth (2010) by falsedan on Monday March 14, 2016 @03:38PM (#11284993)

  > Optimization often involves making code less clear, more
  > brittle, or with a more pasta-like organization.
  > Frequently optimization requires writing code that if
  > looked at out of context, doesn't make sense or might
  > even look wrong.
I agree so much with this. It's better to write a sub-optimal implementation for a component which is clear & can be replaced with a more performant version later, when the bottlenecks have been identified + the interface is well-defined and -tested, and the team can accept the maintenance burden of non-obvious code.

This does mean you can't skimp on good design, making your project a collection of modular, replaceable components.

Re:The 'premature optimization is evil' myth (2010) by HeyImAlex on Monday March 14, 2016 @04:07PM (#11285184)
Further, very often we write code that isn't the code we need to write. I have wasted countless hours on needlessly efficient implementations of the wrong interface, or, on the other end of the spectrum, coming up with the perfect interface for code that will never be used again. Because I like puzzles and optimizing is fun and wiring up business processes is not very fun at all.

But that doesn't mean it's a good way to write software. Accept that most of what devs do is fairly mundane, and focus your mental effort where it's actually needed and you'll be a better developer than anyone who obsesses over the performance/elegance/extensibility of every line they write. Obviously it's a spectrum, and it takes balance, but I know which side I'm currently on!

Re:The 'premature optimization is evil' myth (2010) by falsedan on Monday March 14, 2016 @04:11PM (#11285214)

  > I have wasted countless hours on needlessly efficient
  > implementations of the wrong interface, or, on the other
  > end of the spectrum, coming up with the perfect interface
  > for code that will never be used again.
SAME HERE
Re:The 'premature optimization is evil' myth (2010) by carussell on Monday March 14, 2016 @04:18PM (#11285277)
Examples on either side abound.

I know I've certainly done enough optimizations that left the code clearer and shorter (despite often being more verbose with naming), while being more performant due to shedding whatever messy, tortured approach was in use before. Enough small gains like this have come out of code where I was the original author that it isn't a case of conceit.

Clear and simple code can frequently beat clever code, regardless of which metric you choose to apply from the "performance or understandability" bag.

Re:The 'premature optimization is evil' myth (2010) by falsedan on Monday March 14, 2016 @05:02PM (#11285565)
Simple code is hard tho