• 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: loop efficiency & messages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loop efficiency & messages


  • Subject: Re: loop efficiency & messages
  • From: Ondra Cada <email@hidden>
  • Date: Wed, 23 Mar 2005 00:12:58 +0100


On 22.3.2005, at 23:35, Ricky Sharp wrote:

It's funny that you raise this issue; I just went through this over the weekend. My Carbon basic math app (C/C++) had a unit test such that it literally iterated over every possible user setting and generated math problems. This resulted in just over 1 billion problems being generated with total settings permutations of 1.7 million.

When I first moved my code to Cocoa, I put everything in objects (e.g. a math problem was wrapped in an IIProblem object with appropriate accessors for sum, product, etc.). Over the weekend, I added in the test logic which would pass these objects around and get/set attributes via accessors.

When I ran a small portion of the unit test, it was horribly slow.

I guess the important conclusion of (not just) this story is something what I try to repeat pretty often:


*The Objective C full-dynamic objects and the C++ objects are quite different beasts*

Truth is, they behave *somewhat* similarly, and there is a number of tasks they can be used both the same way, but the differences are deep and important. ObjC objects are heavy and powerful artillery, not to be used lightly: it would be a grave design error to make things like NSPoint or NSRange objects, and it would be a grave design error to use NSNumbers for any computational-intensive tasks, for example. On the other hand, C++ objects are *by far* not that flexible -- but they are quite lightweight (well in my personal opinion, they aren't objects at all: they are just structs on steroids :)).

And the result? Don't ever design the class structure in C++ and ObjC *nearly* the same way.

(to John: of course, the previous statement is wrong in the sense that you can find special cases when the structure can be designed the same way :)))
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: loop efficiency & messages
      • From: Pandaa <email@hidden>
References: 
 >loop efficiency & messages (From: Mark Dawson <email@hidden>)
 >Re: loop efficiency & messages (From: Ondra Cada <email@hidden>)
 >Re: loop efficiency & messages (From: "Corey O'Connor" <email@hidden>)
 >Re: loop efficiency & messages (From: Ondra Cada <email@hidden>)
 >Re: loop efficiency & messages (From: John Stiles <email@hidden>)
 >Re: loop efficiency & messages (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Color of link in NSAttributedString
  • Next by Date: Re: [OT] How to be a real programmer
  • Previous by thread: Re: loop efficiency & messages
  • Next by thread: Re: loop efficiency & messages
  • Index(es):
    • Date
    • Thread