Cocoa with C++, instead of Objective-c?

Member
Posts: 312
Joined: 2006.10
Post: #1
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.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
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.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #3
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
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
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++)
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #5
The syntax of Objective-c just seems very un organized and messy... Now, this Objective-C++, where can I read more about this?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
There's some good info as to the rules at Wikipedia. http://en.wikipedia.org/wiki/Objective-C...ve-C.2B.2B
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #7
Thanks, I think I'll take a look at this language! Do you know the file extension for it?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
It's .mm. It isn't really a new language, it's more of a way to use C++ alongside ObjectiveC.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #9
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++)?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #10
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
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!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #12
it you dont like objective C, you can use java.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #13
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)
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #14
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
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #15
There is java libraries.
Just make a new cocoa java program in Xcode

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Using Cocoa/objective-c in C++ nightition 3 3,582 Oct 3, 2007 11:39 AM
Last Post: MattDiamond