Objective C vs. C++/Java

Discussion in 'iPhone/iPad Programming' started by kage207, May 8, 2009.

  1. macrumors 6502a

    Joined:
    Jul 23, 2008
    Messages:
    943
    #1
    Okay, with me just starting to learn Objective C and just looking at some sample code, it just blows my mind. The transition from Java to C++ was really easy since mainly it was just changing the keywords around and learning a little different rules which wasn't much. So I was wondering if it is just me and that I can't even grasp looking at Objective C.

    The first time I looked at C++ after I had a class in Java, it was the easiest thing ever for me to transition. Mind you I have never programmed on a Mac in my life. This is the first time I'm learning the system. I've only done console application on Windows. I really want to jump into this stuff so I can start programming in the summer in my free time.

    So is it just me? Or why is this so hard? I mean, I guess I knew that it would be a little different since of platform difference and then learning to work outside just one code page because that's mainly what console applications are, one page of code that doesn't really have a GUI.

    EDIT: Btw, Hello World for the iPhone was actually pretty easy to do after following instructions on a website.
     
  2. macrumors 65816

    zmttoxics

    Joined:
    May 20, 2008
    Messages:
    1,021
    #2
    Just different syntax. The books will often replace terms like function parameters with message sending or something like that. How you handle your data / algorithms all still applies. Obj-C also allows for C calls, so if you know C++, you should know some C making the transition not impossible.
     
  3. macrumors regular

    Joined:
    Apr 9, 2009
    Messages:
    244
    #3
    it's not really that hard. it's just a different syntax, that's it. you have strict OOP, messages ... but in the end, it's pretty much the same
     
  4. macrumors member

    Joined:
    Mar 29, 2009
    Messages:
    30
    #4
    You can use Objective-C++ which is allows you to use C++ inside Obj-C by simply changing the file extension from .m to .mm

    That's what I'm doing to reduce the amount of Obj-C I need to learn. e.g: I start an OpenGLES project from the template, change the draw loop to suit my needs then just code all my game objects / logic in C++ and have the Objective-C call into my C++ code.

    Though I guess it's tougher with a cocoa app where you're going to need to wire up all the interface elements in Obj-C.

    "Learn Objective-C on the Mac" and "Beginning iPhone Development , Exploring the iPhone SDK" are great books to get you started.
     
  5. macrumors 601

    Compile 'em all

    Joined:
    Apr 6, 2005
    Messages:
    4,036
    #5
    I am a Java dude and let me tell you this, Objective-C is a pleasure to work with. The syntax is beyond easy and the cocoa touch rocks. seriously!
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Messages:
    15,045
    Location:
    The Centennial State
    #6
    Also, Java was created with C++ in mind and based of its style of notation. Objective-C wasn't.
     
  7. macrumors 6502a

    Joined:
    Jul 23, 2008
    Messages:
    943
    #7
    See, I kind of understand that. But I guess, it's more like compiling the files together to make a program. I've only ever made a program as a console application on Windows. So it runs in DOS. I have never made a program that has a GUI or have used any APIs and I'm downloading all the Podcasts, lectures and such from Stanford on iTunesU (but can't get all of 'em because I have 500MB left on my HDD :eek: ).

    So ya, that's what I'm more asking about? How does hooking up the coding of your algorithms, functions and more to the touch screen API/GUI? I mean, right now I'm in finals and will be starting to delve into this more.
     
  8. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Messages:
    5,988
    Location:
    The Land of Hope and Glory
    #8
    Considering C++ and Objective-C both came from the same language that is a bit of a leap is it not?
     
  9. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Messages:
    15,045
    Location:
    The Centennial State
    #9
    No, it's not. At least not how I see it.

    http://en.wikipedia.org/wiki/Java_programming_language#History

     
  10. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Messages:
    5,988
    Location:
    The Land of Hope and Glory
    #10
    Well yes, the quote you typed just showed my point.

    Objective-C is a direct descendent of C. So is C++.

    Java was influenced by C and C++.

    Therefore Objective-C, C++ and Java all have a common ancestry and syntactic style.
     
  11. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Messages:
    15,045
    Location:
    The Centennial State
    #11
    True, there is definitely a heritage that comes from C. But when the creators of C++ and Objective-C were adding their OOP layer, they made certain style decisions and did things differently. When Java (or Oak really) was being created it also borrowed from the decisions, the ones that were made for C++.

    You must admit that Java is going to look far more familiar to someone comfortable with C++ than Objective-C, right?
     
  12. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Messages:
    5,988
    Location:
    The Land of Hope and Glory
    #12
    Of course, but I just took umbrage with the claim that Objective-C was not influenced by the same syntactic style as C++ when if you look a little closer they have more in common than a lot of other languages do.
     
  13. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Messages:
    15,045
    Location:
    The Centennial State
    #13
    Well, my claim was that Java was not influenced by the same syntactic style as Objective-C. But, of course, there is some influence due to their common C heritage. I guess we just disagree on the extent.

    Anyways, dead horse sufficiently beaten now?
     
  14. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Messages:
    5,988
    Location:
    The Land of Hope and Glory
    #14
    [​IMG]
     
  15. macrumors 6502a

    Joined:
    Jul 23, 2008
    Messages:
    943
    #15
    ...And you guys completely missed the second part of my question...
     
  16. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Messages:
    15,045
    Location:
    The Centennial State
    #16
    Sorry, I don't understand your question. That's really not even a sentence.
     
  17. macrumors 6502a

    Joined:
    Jul 23, 2008
    Messages:
    943
    #17
    Haha, sorry. What I'm saying, how does the touch gestures invoke commands of code on a certain part of the screen? Like do you make a file for each area of the screen? Such as a box that displays email, it has if(Swipe) then show delete button? If that makes anymore sense?
     
  18. macrumors 603

    Joined:
    Jul 29, 2003
    Messages:
    6,308
    Location:
    Silicon Valley
    #18
    How to hook up the UI?

    Instead of functions checking for things, like swipes, with "if" statements, you have objects, and messages get sent to them (by the OS, UI framework, or you) if the swipe happens to meet the requirements.
     

Share This Page