PDA

View Full Version : c++ and objective c




Acorn
Dec 4, 2011, 09:07 PM
I consider myself to have intermediate knowledge of c++. When I looked in to what I should know for mac programming it was suggested that I transition to objective c. Since everything on mac is objective c I tend to agree with this. however when I come here I still occasionally see people trying to learn c++ instead of objective c. is there something about mac programming with c++ i dont know about ?? I just dont want to waste my time learning objective c if in the end i find out i didnt have too.



mobilehaathi
Dec 4, 2011, 09:09 PM
I consider myself to have intermediate knowledge of c++. When I looked in to what I should know for mac programming it was suggested that I transition to objective c. Since everything on mac is objective c I tend to agree with this. however when I come here I still occasionally see people trying to learn c++ instead of objective c. is there something about mac programming with c++ i dont know about ?? I just dont want to waste my time learning objective c if in the end i find out i didnt have too.

If you want to use the Apple frameworks, then you need ObjC. Otherwise, it isn't required at all.

lee1210
Dec 4, 2011, 10:02 PM
You'll need at least some Objective-C to glue your C++ code to Cocoa for GUI and other System frameworks. Otherwise you CAN use your C++ code in the same program (referred to as Objective-C++). I would recommend a very clear delineation between your C++ and your Objective-C code to avoid any messy memory management issues, etc.

If you plan to program for OS X or iOS you need to learn Objective-C. Just do it, don't fight it. It doesn't mean sacrificing the C++ you've learned.

-Lee

foidulus
Dec 5, 2011, 06:50 AM
Objective-C++ is great, but it has some caveats. Nothing too complicated but make sure you carefully read them as they can cause problems in very non-obvious ways. For instance you can have a typedef in Objective-C and C++ with the same name but different definitions. This will compile, but trying to exchange data between Objective-C and C++ will often cause silent data corruption.......

Acorn
Dec 5, 2011, 08:15 AM
You'll need at least some Objective-C to glue your C++ code to Cocoa for GUI and other System frameworks. Otherwise you CAN use your C++ code in the same program (referred to as Objective-C++). I would recommend a very clear delineation between your C++ and your Objective-C code to avoid any messy memory management issues, etc.

If you plan to program for OS X or iOS you need to learn Objective-C. Just do it, don't fight it. It doesn't mean sacrificing the C++ you've learned.

-Lee

I want to try and program for ios. I have a book by kochan i will be starting with. hopefully the book isnt that bad.

firewood
Dec 5, 2011, 11:53 AM
I still occasionally see people trying to learn c++ instead of objective c.

For Mac development, it's mostly ancient legacy code (old libraries) that requires knowing C++. The vast majority of completely new OS X and iOS app development is strictly in Objective C and C.

And if you know basic C++ OOP concepts, getting up to speed in Objective C coding will go much faster than you might think.

Acorn
Dec 5, 2011, 04:38 PM
For Mac development, it's mostly ancient legacy code (old libraries) that requires knowing C++. The vast majority of completely new OS X and iOS app development is strictly in Objective C and C.

And if you know basic C++ OOP concepts, getting up to speed in Objective C coding will go much faster than you might think.

I am hoping so. thanks for the info

Sydde
Dec 5, 2011, 10:26 PM
C++ does have a specific place in Mac OS X, in IOKit. It is the language used for device drivers.

Sander
Dec 6, 2011, 03:54 AM
For Mac development, it's mostly ancient legacy code (old libraries) that requires knowing C++. The vast majority of completely new OS X and iOS app development is strictly in Objective C and C.

Citation needed. Don't use the same marketing trick Microsoft used when pushing C#. When you read "legacy", they want you to think of "dusty, convoluted, old-fashioned". Instead, whenever a marketeer says "legacy", mentally substitute it with "working, efficient, proven".

There is plenty of fresh C++ being coded daily.

KnightWRX
Dec 6, 2011, 05:25 AM
Citation needed. Don't use the same marketing trick Microsoft used when pushing C#. When you read "legacy", they want you to think of "dusty, convoluted, old-fashioned". Instead, whenever a marketeer says "legacy", mentally substitute it with "working, efficient, proven".

Well, in Microsoft's case, if we're talking about MFC when mentionning C++, then "dusty, convoluted, old-fashioned" isn't so far off the mark ;)

Heck, straight Win32 in C was easier to grasp than that junk. :eek:

Sander
Dec 6, 2011, 08:56 AM
Well, in Microsoft's case, if we're talking about MFC when mentionning C++, then "dusty, convoluted, old-fashioned" isn't so far off the mark ;)

Of course. Anything is an improvement over MFC. Unfortunately, I think many programmers who grew up on Microsoft equated C++ with MFC. I grew up on BeOS, and my youth with C++ was quite a bit happier.

Mac_Max
Dec 6, 2011, 11:40 AM
Yeah... I do all my C++ programing on Windows using C++/CLI WinForms just to avoid MFC.

C++ definitely has a place on the Mac. If you have a cross platform app, using C/C++ is a great way to share business logic and model data between various platforms and reduce your testing/code validation efforts/costs. Also from an employment standpoint, it can't hurt to know how to use C++ in an iOS/Mac project.