logoalt Hacker News

fl0kiyesterday at 3:49 PM1 replyview on HN

> Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants.

I get where he's coming from, but I've seen people get this very wrong in practice. They use an algorithm that's indeed faster for small n, which doesn't matter because anything was going to be fast enough for small n, meanwhile their algorithm is so slow for large n that it ends up becoming a production crisis just a year later. They prematurely optimized after all, but for an n that did not need optimization, while prematurely pessimizing for an n that ultimately did need optimization.


Replies

harry8today at 2:26 AM

The error here is not understanding the data being transformed.

You won't get it right either way if you don't /know/ how big n is going to be.

If you can't know, why not? Should you even be coding this at all?

Maybe there should be a rule zero.

0) Understand the data on which your data transformation is going to operate.

The extent you don't is the extent to which the endeavour is doomed.