Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"overhead" of inefficient code

 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do people say it costs more or increases overhead to have inefficient code?

Is it only because of CPU cycles? And really, when we're talking about less than a second, how bad is it, really, to do math or concatenate inside a loop?

What will it cost, a dollar every 1000000000 years?

 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've kind of always assumed that it's CPU cycles, but I've never asked. Interesting question!

In my book readability trumps everything - but if a more efficient way of doing things doesn't interfere with readability, I think making a habit of the more efficient way is just good practice.

On a small scale, it probably doesn't matter so much, but I bet LinkedIn and Twitter and Facebook probably don't want to be redoing the same calculation 20k times when they can do it once, stash the result in memory and just access that.

At my work we have been throwing hardware at inefficient code, which has turned out to be very expensive. Some of my colleagues spent a week getting chummy with the profiler, and reduced the - uh - overhead considerably... it was pretty dramatic, actually.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Katrina Owen wrote:At my work we have been throwing hardware at inefficient code.


Hmmm.... prolly need to buy more monitors. You should think about throwing less fragile things at physical things instead of logical ones.
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it's sooo satisfying!
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Katrina Owen wrote:In my book readability trumps everything ...

Almost always when something becomes more readable, it also becomes more efficient. I think that making something more efficient does not necessarily mean it becomes less readable in the process. So either direction you come from should produce readable, easily maintainable code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic