• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] Premature optimizations (was: Where is NSList?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] Premature optimizations (was: Where is NSList?)


  • Subject: Re: [OT] Premature optimizations (was: Where is NSList?)
  • From: Allan Odgaard <email@hidden>
  • Date: Thu, 29 Jul 2004 23:11:18 +0200

On 29. Jul 2004, at 22:25, Stephen Checkoway wrote:

Programmers are notorious for optimizing the wrong code.
What is your basis for that statement? which programmers are you
referring to?
My basis is that I have done similar things myself and I have watched
others do it.

Which does not qualify for such broad statements. I doubt many experienced programmers would waste their time optimizing in the wrong place, so perhaps I can agree to: "some unexperienced programmers w/o mathematical intuition do on occasion waste their time making improper optimizations" ;)

Not only that, but I have read nearly identical assertions
in nearly every single textbook I have that deals with programming

I am aware of the popularity of this claim, but based on my experience it holds little merit. I think it has gotten popular because many people use interpreted/dynamic languages, and those feel a need to play down the importance of performance (not that I wouldn't agree in many cases).

Though now it's me making the general statements based on anecdotical knowledge ;) all I know is that I have heard it mostly from scripters. None of the people I studied computer science with would say it, nor would they fall for the "premature optimizations..."-thing. And I expect when you say "programmers" you refer to people with at least some degree of education in the field?

However, many times people will start optimizing every piece of code in
sight, not realizing that the real bottle neck is somewhere totally
different (in another thread perhaps) and they are making little or no
difference in the running time.

I assume (again) that "people" refer to some minority of inexperienced programmers. When the OP asks for a linked-list class because he needs O(1) removal, it is downright ignorant to tell him to use an array and lecture him about premature optimizations. So what I disagreed with was that the point was well made and valid _in that context_. In CS 101 it might be a good and valid point to tell people not to spend their time optimizing before they have developed some deeper understanding of how things work (including the mathematical aspects of it).

As an example, how about we consider a list of windows on screen. Lets say
that we want to keep the list sorted and we want to be able to add new
windows in the middle of the list. Now lets assume that each window has
one of those fancy glowing buttons that makes Cocoa apps so pretty. Now if
you decide to be super efficient, you spend your time making the perfect
data structure for this [...]

No you do not, you use std::set! O(lg N) for insert and remove does scale well, and, inserting new windows will require new clipping rectangles to be calculated, even from the theoretical perspective you can easily see that this is the dominating factor. So you are not using the theoretical tools correctly.

[...] 1000 windows all with pulsating buttons needing to be updated at once.

Isn't it only the active window which pulsates?

There was a post on this list a few days
ago about how adding one button caused the processor usage to skyrocket.
Now consider having 1000 of these. Is it really going to matter that it
took a full second to copy 500 of those entries (on average) to delete
that one entry.

So you are saying, because Aqua is a slow GUI, there are no reasons for application programmers to write efficient code, since Aqua will anyway be the bottleneck? ;)

How about we instead say that Apple should improve on Aqua? ;)

A second is most likely far longer than it would really take, but for the sake of argument, lets stick with 1.

Funny you should mention it -- sometimes Mail.app marks my sent messages as unread, that marks the sent message box as having new messages, so to remedy this problem I figured I'd just open up all of them. There were 123 IIRC, and for the next 1-2 hours I could not use my computer, because Mail.app was in the process of opening windows...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: [OT] Premature optimizations (was: Where is NSList?) (From: Stephen Checkoway <email@hidden>)

  • Prev by Date: Re: The problem with bindings
  • Next by Date: A good model header?
  • Previous by thread: Re: [OT] Premature optimizations (was: Where is NSList?)
  • Next by thread: Re: [OT] Premature optimizations (was: Where is NSList?)
  • Index(es):
    • Date
    • Thread