views:

285

answers:

7

I've been coding on C++/Linux for 10+ years.

I am switching to do Mac development.

My development involves GUI components.

Is my only choice to learn Cocoa/Objective-C, or is there a way to wrap Cocoa and use it from C++ land?

Thanks!

+9  A: 

Yes, you need to learn Objective-C. Besides, you wouldn't gain much if you didn't need to. It's not the language that's hard to learn but the Cocoa framework (not because it's inherently hard but because it's so huge).

Ole Begemann
+1, but I wouldn't call Cocoa "hard to learn". It does take time to become familiar with the conventions but that is true of all frameworks.
slf
+4  A: 

No, I don't think you need to learn Objective-C. You can use Qt framework to develop applications on Mac using C++.

erelender
Not if you want them to really work as Mac applications, Qt apps never quite fit in properly on a Mac.
Andrew McGregor
I'm just saying that it is not an obligation, more like an option.
erelender
Qt doesn't quite fit properly on the Mac how? Is the mismatch so bad that one should learn a different (Mac-only!) programming language and a new framework?
rpg
For many folks, the answer is yes - the mismatch *is* worth learning a superset of C (Objective-C is not Mac only BTW) and a new framework. That's obviously a decision each developer will need to make based on the requirements, expected customer, and competitiveness of the market. Fortunately or unfortunately, many Mac users are a bit more discriminating than other platforms and aren't as accepting to the "mismatches" and UI smells.
rcw3
Since Qt is opensource now, shouldn't the Mac community help on this matter? If Qt doesn't fit properly on a Mac, make it fit!
Cristian Adam
There is no reason to make QT fit since Cocoa works just fine. Learning Objective-C is a requirement IMHO to making great (or even good) Mac software. Software that is not written in Cocoa these days looks "odd" and "wrong".
Marcus S. Zarra
+6  A: 

You could use Carbon, but that's deprecated.

As Ole says, Objective-C is not hard to learn if you have a C++ background - and you can mix the languages if you use Objective-C++ (which can be useful, but usually best to partition the code that uses different languages - so use Objective-C/ Cocoa for the GUI layer and C++ for the core logic. I do it this way in my iPhone game, vConqr).

If you've done GUI work in C++ I think you'll appreciate why Objective-C was chosen for Cocoa. It's very nice for event driven designs and has a number of abstractions that are a natural fit. As you get into more abstract areas, though, especially if you use a lot of containers and algorithms, you'll probably start to find the limitations a little annoying. But give it time - there are other useful abstractions that are not immediately obvious (dynamic typing, key/ value coding and other forms of reflection, categories...).

You might also find this stackoverflow question useful.

Phil Nash
A: 

I use WxWindows on the Mac for my tool development. Took a little bit of working but I got my Jam based c++ pipeline that I use on windows working perfectly. The only thing you need to remember to get it all correctly working is to create the proper application rules... easy to get working as a jam rule.

Slazanger
Do you know what's the status on wxCocoa? I've used wxWidgets on Windows and Linux, but never needed to port to Mac.
Emile Cormier
Ive been using wxCocoa for the last few months with a good rate of success. Currently all works fine on 64bit snow leopard. A couple of little gotchas to get it integrated into my build setup, but otherwise fine.
Slazanger
A: 

As mentioned in a few of the other answers, there are a number of cross platform GUI libraries that support mac. Such as Qt and WxWindows. You can use any of them, I personally have only used Qt and found it quite pleasurable to work with after coming from Java and C toolkits.

Neg_EV
A: 

In order to use the native GUI libraries, you can use Python as well (PyObjC). Java is also able to make native looking apps in OS X.

pokstad
+1  A: 

If you are only going to work on Mac apps, then learn Objective-C and the Cocoa frameworks. Cocoa apps can pick up new features "for free" in newer Mac OS X releases, and will be more future-proof than a cross-platform app framework like Qt.

There are so many aspects to Cocoa frameworks (collectively) that you would be best served by sticking to the native app framework to serve your customers (end users). That is really what matters, not the short term inconvenience of learning a new language or framework (which comes with the job, adapt or die).

Pretty soon you will be as frustrated with Xcode as the rest of us.

ExitToShell