iDevGames Forums
Cocoa with C++, instead of Objective-c? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: Cocoa with C++, instead of Objective-c? (/thread-3667.html)

Pages: 1 2


Cocoa with C++, instead of Objective-c? - bronxbomber92 - Dec 2, 2006 10:17 AM

Is it possible to use Cocoa, instead of Objective-C? I prefer C++ much more, and I can't seem to wrap my head around "messages" and how to creat objects, and just the overall syntax Objective-C has added to C.


Cocoa with C++, instead of Objective-c? - akb825 - Dec 2, 2006 11:55 AM

Cocoa requires ObjectiveC, though with ObjectiveC++ you can do most of your code in C++, but the Cocoa parts in ObjectiveC. You could also look up Carbon, which is the root of Cocoa, depending on if everything you need was originally based on Carbon or not.


Cocoa with C++, instead of Objective-c? - bronxbomber92 - Dec 2, 2006 12:15 PM

Damn.... I guess I'll have to learn Objective-C Rasp I bought Aron Hillegasse's book hoping to learn Objective-C and cocoa, but it doesn't teach objective-c well Rasp


Cocoa with C++, instead of Objective-c? - akb825 - Dec 2, 2006 12:18 PM

There really isn't that much to ObjectiveC. (I learned it from Hillegasse's book as well) However, I am like you where I prefer C++, which is why I only use Cocoa for apps that I make that tie in to a standard OS X GUI. (and if the main part of it isn't tied in, I do as much as I can in C++)


Cocoa with C++, instead of Objective-c? - bronxbomber92 - Dec 2, 2006 12:32 PM

The syntax of Objective-c just seems very un organized and messy... Now, this Objective-C++, where can I read more about this?


Cocoa with C++, instead of Objective-c? - akb825 - Dec 2, 2006 12:37 PM

There's some good info as to the rules at Wikipedia. http://en.wikipedia.org/wiki/Objective-C#Objective-C.2B.2B


Cocoa with C++, instead of Objective-c? - bronxbomber92 - Dec 2, 2006 12:41 PM

Thanks, I think I'll take a look at this language! Do you know the file extension for it?


Cocoa with C++, instead of Objective-c? - akb825 - Dec 2, 2006 12:46 PM

It's .mm. It isn't really a new language, it's more of a way to use C++ alongside ObjectiveC.


Cocoa with C++, instead of Objective-c? - bronxbomber92 - Dec 2, 2006 12:48 PM

Oh, thanks a lot! So, assume everything in objective-c is the same as in objective-c++ (except the changes that were made from c -> c++)?


Cocoa with C++, instead of Objective-c? - akb825 - Dec 2, 2006 01:41 PM

ObjectiveC is the same, but you can use C++ constructs alongside ObjectiveC. (I assume you can use some extra things in C++ like for (int i = 0,...), too) You'll generally have an ObjectiveC class to hold your GUI elements etc., then use that to call C++ class's functions, and possibly send messages to your ObjectiveC class from your C++ class's functions.


Cocoa with C++, instead of Objective-c? - OneSadCookie - Dec 2, 2006 03:36 PM

Objective C is a very pleasant, clean, expressive language -- in every way the polar opposite of C++. If you're put off by the square brackets and "keywords" before arguments, you're doing yourself a serious disservice. Just 'cos it doesn't look like C is no excuse to dismiss it out of hand!


Cocoa with C++, instead of Objective-c? - unknown - Dec 2, 2006 04:55 PM

it you dont like objective C, you can use java.


Cocoa with C++, instead of Objective-c? - akb825 - Dec 2, 2006 05:10 PM

Or not. Rasp (I personally despise Java, though opinions do vary)

As OSC pointed out, ObjectiveC is quite different in philosophy than C++. Then again, being different doesn't necessarily mean better. ObjectiveC is more about being simple and small. C++ seems to be more about making all types equal (such as with operator overloading, which allows it to not rape primitives the way Java does) as well as having tools to make those types easier to use. (such as templates and references) I suppose a replacement for templates in ObjectiveC would be id, but I don't like it as much for 2 reasons: we get back to the raping of primitives, and though it's kind of nice to be able store anything, type checks can be very useful for catching bugs before they happen due to compiler errors. (besides, you always have the choice with void * in C++) I would have to say, sending any message to anything is pretty nice, though, since it makes receiving messages from UI elements very easy. Although we once again get to the compiler being less of a help. (it will throw warnings saying that a message can't be found, but I honestly get more warnings because one of my classes has a slightly different format but same name as another class', usually in the Cocoa library, or that it doesn't see a message that actually is there)


Cocoa with C++, instead of Objective-c? - bronxbomber92 - Dec 2, 2006 07:36 PM

I'm not saying I refuse to learn it, but I wanted to make sure there wasn't an easier (or familiar) option for me, instead of Obj-C.

How can Java be used with it? I know C# can use cocoa# also, but cocoa# isn't very far in development Sad


Cocoa with C++, instead of Objective-c? - unknown - Dec 2, 2006 07:59 PM

There is java libraries.
Just make a new cocoa java program in Xcode