|Aug 7, 2007, 11:33 AM||#3|
Objective C's Foundation Framework has classes that do the same work with STL's classes.
For example, look at the C++ - ObjC equivalents:
strings -> NSString
Vectors ->NSArray and NSMutableArray
Maps -> NSDictionary
Now, queues, stacks, etc are derivatives of vector, and in ObjC will not have a significant performance advantage of being developed, since NSArray already stores elements in a dynamic manner, using pointers. And it accepts any derivative of NSObject. There are some fundamental differences, though, for example in an NSArray in location 1 you can put an NSString, but in location 2, you can put an NSDictionary.
If you want to use the STL, you can use C++ within ObjC. But let me give you some advice. Use C++ with ObjC only if you have to. Even if you want to port a program from C++ to ObjC, things can be really messy and you could end up writing spaghetti code if you don't know what you're doing. ObjC more than matches the capabilities of C++. Use C++ only for accessing low-level mechanics of an application.
|Aug 7, 2007, 01:16 PM||#4|
FYI, Soulstorm, adts (or ADTs) are "Abstract Data Types" which you've correctly guessed the meaning of.
Objective-C doesn't have templates (I don't have direct knowledge of what's on tap for Objective-C 2.0, but I don't believe any kind of generics is being added).
Objective-C/Cocoa uses a single-root style of object oriented framework. Collection classes, therefore, contain pointers to objects. Cocoa has various collection classes and gobs of other useful objects built in.
It's not quite as efficient as templated container classes can be, and it's not as type-safe. On the other hand, Cocoa is a really nice environment to develop in.
Anyway, Objective-C really takes a more dynamic, run-timey approach to objects than C++, which is counter to the static, compile time nature of templates. To get the full benefit of templates in Objective-C you'd have to lose the dynamic nature of objects used with them. And If you keep the full dynamic nature of Objective-C objects, you'd have to lose most of the benefits of templates.
As someone who came from a hard-core C++ background to Objective-C, Cocoa/Objective-C has really won me over. As a developer I think it gives you a lot more than you lose. I think a lot of it has to do with how nice the Cocoa framework is, really.
|Aug 7, 2007, 02:06 PM||#5|
To all that, I want to add that C++ will never be replaced by ObjC and vise versa.
C++ is for closed world situations (like designing the engine compartment of a car) and ObjC is for open world situations (like designing the interior of the car and its behavior on the road). And, there are some features of OS X that you can't touch without using C++, like some Core Foundation features. I know, those features are also accessible using C, but who uses C when he knows how to use C++?
However, ObjC is really the best choice for OS X development. The ease, power and flexibility that Cocoa provides are unmatched.
|Aug 8, 2007, 04:43 PM||#6|
on that note then what would be the best book to purchase to teach me the best ways to use the cocoa framework. Im very confident using c++ and obj-c (i read though a rather lengthy tutorial on it already and its obviously very similar to c++) so i'd like a book centered on just the tools and frameworks osx provides to build applications.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Trying to convert object to NSMutableArray||johnmerlino||iPhone/iPad Programming||4||Nov 11, 2011 03:08 AM|
|How to get pointer to object||svjim||iPhone/iPad Programming||2||Sep 17, 2008 10:25 AM|
|Date: From String to Object, Back to String||Fontano||Mac Programming||3||Aug 29, 2008 07:23 PM|
|Objective-C newbie: Copying object to object||NickFalk||Mac Programming||11||Aug 13, 2008 09:59 AM|
|A tutorial on how to refer to objects in AppleScript Studio ...||MacBytes||MacBytes.com News Discussion||0||Sep 22, 2003 08:56 AM|
All times are GMT -5. The time now is 08:56 AM.