Re: What is the purpose of static typing?
Re: What is the purpose of static typing?
- Subject: Re: What is the purpose of static typing?
- From: Philip George <email@hidden>
- Date: Wed, 24 Jul 2002 21:27:32 -0500
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.
I just created a test app with two nswindows (programatically) created
and each has 50 nstextfields. win1 and it's 50 textfields are all typed
as "id" while WIN2 and it's 50 textfields are statically typed.
all of the creation code and addSubview code is done in separate methods
that are executed in as separate threads upon clicking a button.
after app launch i click the button, whose action method detaches the 2
threads like so:
- (IBAction)myAction:(id)sender {
[NSThread detachNewThreadSelector:@selector(winONE:) toTarget:self
withObject:nil];
[NSThread detachNewThreadSelector:@selector(winTWO:) toTarget:self
withObject:nil];
}
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.
In small doses, it's not very noticeable, but if you overuse id, it does
start to become noticeable to the user.
- Philip
On Wednesday, July 24, 2002, at 08:24 PM, Richard Wolf wrote:
>
*This message was transferred with a trial version of CommuniGate(tm)
>
Pro*
>
> Additionally, as a rule of thumb, the more dynamic typing you use, the
>
> more sluggish your user experience will become.
>
>
Whoa ... unless I'm reading my Objective C manual and misunderstanding
>
it, there -can't- be any -runtime- difference between objects
>
statically and dynamically typed in source because all methods are
>
dynamically bound to objects at runtime.
>
>
The way I read that,
>
>
NSTextField *tf;
>
...
>
[ tf setStringValue: @"Some string" ];
>
>
and
>
>
id tf;
>
...
>
[ tf setStringValue: @"Some string" ];
>
>
are equally efficient and there is no way that one could be more
>
efficient than the other. To the runtime, they are supposed to be
>
exactly the same, right? Or, am I not reading the books correctly? I
>
speak as a newbie.
>
_______________________________________________
>
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.
_______________________________________________
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.