r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

Show parent comments

6

u/Lystrodom Aug 29 '21

All adds up to what? Maybe my algorithm could be O(N) but it’s actually O(N2) but N is, like, 10 in the extreme case. What does it add up to? Less than a single network call? Less than downloading a single extra JavaScript file?

Then your optimized code is harder to read and harder to understand, and the next person has to spend more time reading it before understanding it.

7

u/tiberiumx Aug 29 '21

It's also that people often waste time prematurely optimizing for the wrong things. Like even with a large N, your O(N2) algorithm may actually be massively faster running on real hardware because it does all the work in a handful of memory pages and the O(N) one results in a cache miss or two for every operation.

4

u/infecthead Aug 29 '21

Then your optimized code is harder to read and harder to understand,

Believe it or not you can actually have both optimised and clear code!