Why would a pointer ever be useful? (Java Background Explanation)

Pointers are unique to lower level languages like C++ and C. Higher languages, like Java or Python have removed the use of pointers due to complexity…if the user fails to understand their code.

This may be helpful for someone coming from a Java background, but it’s important to note you can NOT pass by reference in Java. That means, only the value is passed to this method call, foo(x); where x could be any class deriving from the Object class.

Okay, that’s fine and dandy and all, but here is where the beauty of a lower level language like C++ comes in.

If we already have a reference to some object in memory, why on earth would we waste computational power to recopy that object’s value when we could just give the method the memory’s reference?

This makes C++ a fast language while at the same time being memory efficient if implemented correctly. Java eliminates the need to ever have to worry about that, but you are taking a performance hit. When it comes to game development, we want all the performance we can get, therefore, C++ is the best compromise.

Hope this helps! Pointers are your friend :smile:

Privacy & Terms