Re: ObjC 3D engine
Re: ObjC 3D engine
- Subject: Re: ObjC 3D engine
- From: John Stiles <email@hidden>
- Date: Mon, 25 Jun 2007 15:46:36 -0700
On Jun 25, 2007, at 2:45 PM, Uli Kusterer wrote:
On 25.06.2007, at 18:59, Kaelin Colclasure wrote:
Second, if you *must* use C++ keep it isolated into dedicated (and
hopefully small), performance-critical modules -- ideally that are
compiled as a separate target from the bulk of your project. I
recommend against falling into the practice of using ObjC++ for
all of your sources. Your compilation times suffer, and more
insidiously the incompatibility between ObjC and C++ exceptions
makes it extremely tricky to use either safely.
I can definitely attest to that. You don't want to run the ObjC++
compiler on even one more file than you need to.
I guess the only question remaining, then, is whether the bulk of the
app is in C++ or ObjC (either of which should compile quickly
enough). Of course, if you're in my line of work this decision is
made for you by the Windows guys ;)
Personally, I'd create a Cocoa wrapper class that looks like
NSArray from the outside and uses STL only on the inside. Or even
better, just write your own code with an NSMutableData block as the
backing store for a C array. Or just malloc a block, whatever
floats your boat, man. If you're really only using std::vector,
that should give you about the same performance if you know any
algorithm basics.
I am darn near positive that I saw a wrapper which let you use
vectors and NSArrays interchangeably somewhere, but I cannot remember
where :(
The only types where it would be worthwhile are std::map and a few
other of the more complex STL types.
Speaking of this, is there any equivalent type to set<> or map<> in
Cocoa? There are arrays and hash table types, but are there any
ordered-container types? I was dealing with this just recently and
ended up using an NSMutableDictionary along with a line I am not
proud of:
return [dict objectForKey:[[[dict allKeys]
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]
objectAtIndex:index]];
I kept telling myself, "this isn't going to be used in shipping code,
it's fast enough, who cares" but in the back of my head I'm still
trying to think of alternate solutions…
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden