As we know that in c/c++ pointer concept are present and pointer concept is a very good one.Then, Why the java developers remove it and if we can't use in java the what is it's pros and cons.
Asked
Active
Viewed 4,885 times
0
-
one of the major selling point of Java to incompetent C/C++ programmers "No more pointers" movement(I will now be flamed) – Aniket Inge Mar 13 '13 at 05:14
-
1It's more like Java has pointers, but it manages them in a safe fashion. – Thilo Mar 13 '13 at 05:15
1 Answers
1
Pointers are forbidden in managed languages by default to allow memory management to be opaque - for example, you can have a compacting garbage collector that moves objects closer together to free up larger blocks of free space and improve cache coherency, if there are no pointers. But if there are pointers, then every pointer would either need to be updated or become valid every garbage collection, which is infeasible.
(This is just one reason of course :) but an example of how allowing pointers drastically changes what your programming language can do )
In some managed languages, like C#, you can declare unsafe {}
blocks, where you can used unmanaged memory and pointers, but only there.

Patashu
- 21,443
- 3
- 45
- 53