Tuesday, October 27, 2015

Shouldn't we aspire to optimize [code] everywhere?

[Searching through my long list of partially finished blog posts I found this. I think the principles are still relevant so posting it now.]

Last weekA [long] while ago I wrote a post about how I've seen a change in the places where it's important to write optimized code.
One of the responses I got was that "shouldn't we aspire to optimize [code] everywhere?"
This strikes me as the result of a very developer/code focused reasoning and is, I feel, a topic worth discussing further.

Let's start by looking at this from a purely developers perspective. By which I mean we're only thinking about the code and there are no other considerations.

Given no other constraints then it may be fine to spend indefinite amounts of time on optimizing code. That is, getting it to run faster or use less memory or any other attribute by which we may measure code.
But to what end?
What benefit does such optimization bring? We may be able to say it's better but if that only benefits our developer mentality then is it worth it?

For most of the time there are external constraints when writing code. If writing for someone else (say as part of your job) there's probably a time and cost constraint. Either code must be written by a certain date/time or there is only so much budget to pay for the development effort.

Even if we are writing code for our own use then there will be a point when it's "good enough" to use. Yes we might be able to make it better than that but should we? If we want to keep making it better then at what point do you stop? If it's theoretically possible to make it faster do you put off shipping?

But what are we optimizing for in the first place?
Because we can?
Or because it will provide a measurable benefit?

On .net rocks show #1003 there was discussion about the value of performance improvements and the following claim:
“The threshold of perception is 2%. The threshold of meaning is 20%”
This means that if you can’t make it 20% better (faster) then the user won’t care.

Do you really need to spend a lot of time optimizing your code for only a small performance improvement? Probably not.
But yes, also a difficult discussion to have when you have to optimize performance to hit some arbitrarily defined number. (If you've ever had a project where someone has decided that X must be done in 300 milliseconds and you're busy trying to get it down from 305 then you have my sympathies.)


Yes, performance is a feature and yes you should make things as good as you can. Just remember to balance them against being usable and good enough.






5 comments:

  1. A graduate student went on a Louis Vuitton Outlet weeklong hunger strike.Wolfe's announcement came at the start of what had been expected to be a lengthy closed-door meeting of the school's governing board.

    ReplyDelete
  2. Where Michael Brown was killed last year in a Gucci Replica Handbags fatal shooting that helped spawn the national "Black Lives Matter" movement rebuking police treatment of minorities.

    ReplyDelete
  3. As for me I prefer using essaywriterservice because there are a lot of helpful things there for students who need a perfect essay quickly! Thanks a lot for the information about it! This service is a real way out for me and many others

    ReplyDelete
  4. 1:1 replica watches sale for men and women online. Rolex replica, Swiss replica watches or Breitling replica watches on the best replica site.Gentlemen's publication Esquire explores the history of the Replica Watches.

    www.thenicewatch.co.uk

    ReplyDelete