discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C and Smalltalk; speed of message send


From: Adrian Robert
Subject: Re: Objective-C and Smalltalk; speed of message send
Date: Thu, 19 Aug 2004 10:24:29 -0400


On Aug 18, 2004, at 3:49 PM, Marcel Weiher wrote:

Whoa, an NSDictionary is a pretty heavy-weight item, especially compared to a simple 2D array! Why not stick with the 2D array, if I may ask? After all, one of the point of Objective-C is that it *is* C.

 We decided to use NSStrings as the keys.

Also potentially fairly heavy, though a common choice. I remember people complaining about NSString's performance compared to char* when Foundation was introduced. However, NSString is really for "human readable" text, whereas char* is often more for "tokens", or really just byte-sequences.

To maintain a backwards bridge, we took the old 2D access indices and turned them into a string. And then stored/set them in the NSMutableDictionary via those. The performance was not impressive.

I wouldn't expect it to be. NS(Mutable)Dictionary is pretty slow. One issue is that it copies its keys. Arrrggghh.

While it's good to have the raw C capabilities there for extreme cases, it's NOT much good having a nice, high-level API if it's so slow you end up dropping back to mid-level C (with all of its tedium and error-proneness) much of the time. I'm going to get in trouble here for talking instead of sending code ;), but it seems like the class NSString and at least the plist classes NSDictionary and NSArray ought to be as optimized as well as they can possibly be. These are used everywhere in the libraries and in applications, and effort in this direction should pay off handsomely. I'm sure much has been done already, but perhaps there is still some reasonably low-hanging fruit remaining?

I realize there are things that just have to be done for correct behavior (e.g., hash key copying), but I just don't see how any Smalltalk environment should be able to match Objective-C in performance for a straightforward application of strings and dictionaries. We ought to look at these implementations (if any have source available) and see what techniques they are using.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]