Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Acorn

macrumors 68030
Original poster
Jan 2, 2009
2,642
349
macrumors
Ive been using c++ for the past couple of years and was wondering if i wanted to program for mac does that mean I have to switch to objective c.
 

Mac OS

macrumors newbie
Jul 1, 2011
2
0
That will depend on what you are planning to accomplish on the Mac.

You can build non-GUI applications entirely in C++ just like you would in any other environment. Xcode, Apple's IDE, fully supports C++ (as well as Obj-C++, a combination of both languages, albeit with some limitations).

You can also build GUI apps using C++ exclusively, but you will probably want to take advantage of all the APIs Cocoa, Mac OS X's native programming platform, has to offer. Most Cocoa's APIs, including the APIs that deal with the GUI, are based on Obj-C. You can try to use "bridges" to access the Cocoa APIs using C++. IMHO, given that both are C-based languages, it shouldn't take you more than a couple of months to master Obj-C if you are fluent in C++. Everything's pretty simple in Obj-C, save some aspects of its dynamic runtime that are not possible in C++. By using Obj-C, you'll make Apple happy, and you'll make sure your code will work in the future.

Good Luck!
 

PatrickCocoa

macrumors 6502a
Dec 2, 2008
751
149
Short Answer: Yes

Long Answer: Yes, you do need to learn Objective-C.

Longer Answer: Yes, you do need to learn Objective-C, it will be easier in the long run than trying to shoehorn your current knowledge into the Mac world.
 

Madd the Sane

macrumors 6502a
Nov 8, 2010
534
73
Utah
Wirelessly posted (Mozilla/5.0 (iPod; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5)

If you use WxWidgets, Apple does supply a version on Mac OS X. However, the version bundled with Snow Leopard uses Carbon APIs, and thus limited to 32-bit apps. You can compile a beta version that uses Cocoa, but you have to explicitly tell it to do Cocoa or it'll do Carbon.
If you want to do some serious app development on OS X, I reccomend learning Objective C. It's not hard to learn, and will make your apps more Mac-friendly.
 

Madd the Sane

macrumors 6502a
Nov 8, 2010
534
73
Utah
Wirelessly posted (Mozilla/5.0 (iPod; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5)

Just look in the /usr/lib/ for it. It also includes the configure script to help you build (wx-config), but I think the headers are installed with Xcode.
 

GorillaPaws

macrumors 6502a
Oct 26, 2003
932
8
Richmond, VA
If you know C++, then learning Objective-C will be a breeze (it's just a small extension to the C language). The thing that takes time is learning the Cocoa Frameworks, and there's really no getting around that if you want to write an attractive native Cocoa app.
 

duggram

macrumors 6502
Apr 17, 2008
390
11
What about using CodeBlocks and WxSmith? Does it really create cross platform C++ apps? Anyone with experience?

What I'm trying to ask is, can you do Mac application development using CodeBlocks?
 
Last edited:

PatrickCocoa

macrumors 6502a
Dec 2, 2008
751
149
Steve says: Cocoa!

What about using CodeBlocks and WxSmith? Does it really create cross platform C++ apps? Anyone with experience?

What I'm trying to ask is, can you do Mac application development using CodeBlocks?

Mac users expect (or demand) "Mac-like" applications. Mac users hate cross platform apps.

You must use Cocoa.
 

ehoui

macrumors regular
Jan 27, 2011
217
0
What about using CodeBlocks and WxSmith? Does it really create cross platform C++ apps? Anyone with experience?

What I'm trying to ask is, can you do Mac application development using CodeBlocks?

Or curses. Screw the user.
 

Mac_Max

macrumors 6502
Mar 8, 2004
404
1
Cocoa isn't necessary and in all honesty I suggest using the Obj C++ approach as much as possible unless its only going to be a Mac only piece of software. Lots of Mac GUIs are made using QT, GTK, and even with C#/WinForms/GTK/QT care of Mono. I believe you can find example programs on the respective sites of those toolkits.

Some do better than others at following UI standards and others intentionally throw them to the wind in order to have a unique and consistent UI across conflicting platform standards (i.e. emulating an MFC MDI type app on the Mac because the Windows and Linux versions work that way).
 

GorillaPaws

macrumors 6502a
Oct 26, 2003
932
8
Richmond, VA
Lots of Mac GUIs are made using QT, GTK, and even with C#/WinForms/GTK/QT care of Mono. I believe you can find example programs on the respective sites of those toolkits.

Can you give some examples of apps that have done this well, and provide a quality end-user experience?
 

mdatwood

macrumors 6502a
Mar 14, 2010
917
893
East Coast, USA
If you know C++, then learning Objective-C will be a breeze (it's just a small extension to the C language). The thing that takes time is learning the Cocoa Frameworks, and there's really no getting around that if you want to write an attractive native Cocoa app.

QFT. Obj-C is an easy language for anyone with C experience and some OO under their belt. The hard part of OSX/iOS development is not obj-c, but learning all the frameworks.
 

Yair1978

macrumors newbie
Jul 10, 2011
3
0
What??? But.......

I'm returning to programming after some 10 years. Then I mastered basic Pascal and C and I've decided to try to get back into things. My natural choice was c++, as I'm under the perception that this language is pretty basic to many other languages as well as still widely used.

Now, I have a Mac.... But I don't really want to learn anything that's ONLY for Mac, but still I want to do my learning on the Mac... Should this be such a problem? Learning C++ on a Mac? Is there no way to at least build simple GUI applications using C++ on a Mac?

Please note that my question is a bit different from the original one. I'm not a programmer who's already savvy in C++ and who wants to develop for Mac. I want to get into programming....

/Yair
 
Last edited:

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
Is there no way to at least build simple GUI applications using C++ on a Mac?

The problem is that GUI APIs are platform specific. For your own consumption Qt or some other third party "middleware" framework would do, but these apps tend not to look like real "native" Mac apps as previously discussed in the thread.

One big thing to learn as far as GUI programming goes is to separate your code into parts. The UI should be separate from the code that actually does "the work". Apple's Cocoa and Objective-C reinforce this by pushing Model/View/Controller (MVC) http://en.wikipedia.org/wiki/Model–view–controller throughout.

This allows you to make the model portable, potentially in C++, and to write a GUI on top of that in Objective-C for OS X or C# for Windows...

B
 

Yair1978

macrumors newbie
Jul 10, 2011
3
0
The problem is that GUI APIs are platform specific. For your own consumption Qt or some other third party "middleware" framework would do, but these apps tend not to look like real "native" Mac apps as previously discussed in the thread.

Thank you for the answer!

Just a few more clarifications, though... ;-)

1. Just to get into programming then, am I going at it backwards starting off with c++ on my Mac? Should I just change language (perhaps Java, then?) or change platform (have Windows through Bootcamp, just that it's annyoing to have to reboot).

2. If I do choose to stick with my original plan (c++ and my Mac), will xCode not do the job? All tutorials seem to start off with doing a "hello world" through a console application, which is not really where I necessarily want to be "stuck"...

/Yair
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
IMHO if you are going to focus on GUI programs you need to pick one of two paths.

Learn a cross-platform UI framework and library and use that knowing that your apps will never seem perfectly native, and native programs will also outperform it. (Java fits in here too).

or

Pick a platform and environment and learn the language most appropriate for that platform. If that's Mac learn Objective-C/Cocoa in Xcode, for Windows I'd pick C# in Visual Studio.

It really depends a lot on where you want to go with this and what kind of applications you want to develop.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.