On Wednesday 23 February 2005 17:32, Gareth Williams wrote: > On Wed, 23 Feb 2005 15:29:02 +1300, HappyEvilSlosh > > > > Or pointers for that matter. > > > > I understand that it's more you can't see them rather than they aren't > > there, hence the pointer exceptions java sometimes throws. > > Java lacks explicit pointers. You can't use them yourself, but they're > used by the underlying mechanism (and called "references" I believe). > So although this adds a little simplicity, the programmer is still > required to understand the concept of pointers and how they behave. > Which kinda defeats the purpose of concealing them IMO.
They need to understand dynamic allocation and lifetime concepts. The most difficult issue programmers have with dynamic (heap) allocation is not allocation or the syntax for (de)refencing objects, it's deleting the damn things when they are no longer referenced. That's one thing Java via automatic garbage collection does simplify for developers. A Java reference is akin to a C++ reference at least in syntax. A pointer presumes an underlying implementation and languages such as C/C++ that have pointers support 'pointer arithmetic' as alluded to elsewhere in this thread. On the other hand an 'object reference' need *not* be implemented as a memory address and since it doesn't need to behave like a simple address, an object reference could reference a non-resident object persisted in a database on a different machine (for example).
