A java guy's view of pointers

Discussion in 'iOS Programming' started by nashyo, Apr 14, 2013.

  1. nashyo macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #1
    A java guy asked me, "In a nutshell, explain why Objective-C uses pointers". I couldn't answer!

    Does anyone know?
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    Because Obj-C is a perfect superset of C which used pointers.

    Also because it makes it a lot more obvious when you're passing by references vs. by value (I often get confused about whether a function is dealing with an original object or a copy of an object in Java.)
     
  3. ArtOfWarfare, Apr 14, 2013
    Last edited: Apr 21, 2013

    ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    Here's a counter-question for your Java friend,

    Why do I have to deal with "NullPointerException"s all the freaking time in a language that supposedly lacks pointers? It seems to me that Java kept the pointers and simply dropped the syntax, which helped inexperienced programmers but just confused anyone who had ever worked with any other language.

    I think my favorite system when it comes to this is C++ with their & pass by reference... it has most of the flexibility with pointers minus a lot of the headaches (and unlike Java, they leave it totally up to you if you'd like to revert to ordinary pointers for whatever obscure task you have where & references won't cut it.)
     
  4. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #5
    They're not pointers they're tickets for the C train.
     
  5. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #6
    "Because that's how computers really work, and C, Objective C, and C++ are closer to the machine than Java."

    Java is an abstracted language that runs on a virtual machine. It hides whats really going on from the developer.

    I'm an old assembler jockey. Java's disconnection from reality drives me nuts.
     
  6. nashyo thread starter macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol

Share This Page