Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm developing GUI apps on Mac. I have been using C++ for 10+ years. Do I need to switch to Objective C?

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!

like image 428
anon Avatar asked Jan 21 '10 13:01

anon


4 Answers

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).

like image 69
Ole Begemann Avatar answered Sep 22 '22 07:09

Ole Begemann


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.

like image 27
philsquared Avatar answered Sep 22 '22 07:09

philsquared


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

like image 38
erelender Avatar answered Sep 23 '22 07:09

erelender


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.

like image 39
ExitToShell Avatar answered Sep 26 '22 07:09

ExitToShell