• 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: What is the purpose of static typing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the purpose of static typing?


  • Subject: Re: What is the purpose of static typing?
  • From: Marcel Weiher <email@hidden>
  • Date: Thu, 25 Jul 2002 10:10:26 +0200

On Thursday, July 25, 2002, at 04:27 Uhr, Philip George wrote:

They're bound "as needed" during runtime, not at applaunch, so as users
pop open new windows (for instance) they are bound at that moment. Once
bound, it's smooth sailing, but the user does have to wait for binding
to take place that very first time that object is used/referenced.

That's not entirely correct. The binding takes place each time a message is sent, in the function objc_msgSend(). This function does feature caches to optimized lookups, but it's not a one-time only affair, as entries can be displaced from the cache etc.

- (IBAction)myAction:(id)sender {
[NSThread detachNewThreadSelector:@selector(winONE:) toTarget:self
withObject:nil];
[NSThread detachNewThreadSelector:@selector(winTWO:) toTarget:self
withObject:nil];
}

This test will tell you nothing, except maybe how threads are scheduled...and probably not even that.

Notice that I give the 'id' window a head start. Even with the head
start, the 'id' window is drawn **long** after the statically typed
window and it's statically typed textfields are completely drawn to the
screen.

This has nothing to do with static typing. For one, your tests don't actually measure what you think you're measuring. Probably just noise, maybe some drawing/windowing effects.

The *total* messaging overhead for *50* message sends is going to be on the order of a couple of microseconds ( 2.5 microseconds on a 1 GHz G4, around 50 nanoseconds per message send). So even if static typing completely eliminated the send, the difference would be no more than 10 microseconds on any hardware that OS X is supported on.

I challenge you to pick out a 10 microsecond difference visually :-) Heck, not even measuring with 'time' will pick that up, the timers don't have that much resolution.

So if you're seeing a noticable difference, they're not due to messaging performance.

In small doses, it's not very noticeable, but if you overuse id, it does
start to become noticeable to the user.

No. This is completely wrong. Stepstone Objective-C used to be able to bind methods statically. Apple/GNU Objective-C does not. There is no runtime performance difference attributable to static type declarations of classes (unless you count making instance variables public and then accessing them directly w/o messaging...)

Marcel

--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.

  • Follow-Ups:
    • Re: What is the purpose of static typing?
      • From: Ondra Cada <email@hidden>
References: 
 >Re: What is the purpose of static typing? (From: Philip George <email@hidden>)

  • Prev by Date: Re: What is the purpose of static typing?
  • Next by Date: Re: Retain/release objects in an array...
  • Previous by thread: Re: What is the purpose of static typing?
  • Next by thread: Re: What is the purpose of static typing?
  • Index(es):
    • Date
    • Thread