c++ and objective c

Discussion in 'Mac Programming' started by Acorn, Dec 4, 2011.

  1. macrumors 68020

    Acorn

    Joined:
    Jan 2, 2009
    Location:
    macrumors
    #1
    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.
     
  2. macrumors 603

    mobilehaathi

    Joined:
    Aug 19, 2008
    Location:
    The Anthropocene
    #2
    If you want to use the Apple frameworks, then you need ObjC. Otherwise, it isn't required at all.
     
  3. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    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
     
  4. macrumors 6502a

    Joined:
    Jan 15, 2007
    #4
    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.......
     
  5. thread starter macrumors 68020

    Acorn

    Joined:
    Jan 2, 2009
    Location:
    macrumors
    #5
    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.
     
  6. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #6
    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.
     
  7. thread starter macrumors 68020

    Acorn

    Joined:
    Jan 2, 2009
    Location:
    macrumors
    #7
    I am hoping so. thanks for the info
     
  8. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #8
    C++ does have a specific place in Mac OS X, in IOKit. It is the language used for device drivers.
     
  9. macrumors 6502

    Joined:
    Apr 24, 2008
    #9
    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.
     
  10. macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #10
    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:
     
  11. macrumors 6502

    Joined:
    Apr 24, 2008
    #11
    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.
     
  12. macrumors 6502

    Joined:
    Mar 8, 2004
    #12
    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.
     

Share This Page