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

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
A java guy asked me, "In a nutshell, explain why Objective-C uses pointers". I couldn't answer!

Does anyone know?
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,563
6,062
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.)
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,563
6,062
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.)
 
Last edited:

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
A java guy asked me, "In a nutshell, explain why Objective-C uses pointers". I couldn't answer!

Does anyone know?

"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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.