Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"The issue is that you don't understand that the value of a Java object reference is the same as a C++ pointer"

A C++ pointer is a simple thing: an address within the program's address space. In an earlier response to a similar claim of yours, RayleyField pointed out that "In HotSpot references are double pointers (useful for moving GC), but in general it's up to JVM implementation." Certainly, if you dig into a Java reference, you will find an address that is analogous to a C++ pointer, but the same can be said of a C++ reference. Java references are not exactly equivalent to either C++ references or C++ pointers, and the statement that Java passes by value is not dependent on an arguable claim that Java references are more like C++ pointers than C++ references. This line of argument has just added to the confusion in these threads.



We are talking logically, not implementation details.

Logically, a C++ pointer and a Java object reference are nearly identical, as described and defined by their respective language standards. Independent of the implementation chosen.

This is not the same as a C++ reference, which is logically an alias (and may be implemented via pointers, but that's irrelevant).

The confusion in this thread stems from people confusing many things, indeed.


If "we" are talking logically, then "we" should not be using the expression "C++ pointer" in the statement I quoted earlier. Doing so can only lead to confusion in the minds of people struggling to understand Java argument-passing.


Why not? A C++ pointer is a logical construct that exists in the language (as per the language standard) independent of any given implementation.

Same with "Java object reference" and "Java pointer" (synonyms).

If we can't discuss this topic using those well-defined things, what can we use?


'If we can't discuss this topic using those well-defined things, what can we use?'

I am told you will find all the things you need well-defined in the JLE, and in doing so you will avoid positing a plurality without necessity, as Billy Ockham may or may not have put it.


JLE? Or JLS? If you mean the spec (JLS) then I agree, you can find everything there. Including what I wrote above - that "Java object references" are the same thing as "Java pointers" (both in the JLS). The JLS also describes parameter passing in excruciating detail, and it matches the definition of "pass-by-value" (not "pass-by-reference") exactly.

But if people in this thread could read and understand the JLS, this thread wouldn't exist. Since it does, some of us feel like we should contribute and correct the false statements we see.


You are right, JLS. With regard to whether these comparisons with C++ have led to the desired results, see elsewhere.


The well-definedness of 'C++ pointer' is a non sequitur - it is not a sufficient condition to justify its use in this context. 'Backwardation' is well-defined, yet I doubt it can contribute anything to this discussion.


If you consider the context of my statement, and not my statement as it stands in isolation, then you are mistaken.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: