Winston Gutkowski wrote: If you didn't have polymorphism, what would your code look like?
This is a question that C programmers have wrestled with for many years.
Winston
"That might be true for C, but Java doesn't use assembler. "
but it certainly is not being placed directly onto a register since registers aren't big enough to hold 1MB of data
Dave Tolls wrote:Every time I see this discussion I think "surely this is the last time", but it seems to reappear every few years.
I've been living in hope for over 15 years.
Stephan van Hulst wrote:Shawn, I hope this has made it clear why we say Java passes everything by value? The thing is that the only values Java can pass are primitives and references. Passing an object by reference is different from passing a reference by value, as I've tried to explain with my examples.
(although in Java it can be a magical lamp).
Campbell Ritchie wrote:
A reference may hide a handle rather than a pointer. A pointer must point to the exact memory address. You use direct indexing for one and you use indirect indexing for the other. And that is not a philosophical statement. The fact that Java® fortunately hides all those details from you doesn't mean they don't exist.Shawn Lau wrote:. . . Whats the practical difference between a method and a function? Reference - pointer? Any difference? . . .
I think a lot of this has been said already. I also think this discussion is no longer suitable for the “beginning” forum and I shall move it.
It is difficult.Campbell Ritchie wrote:That might be because of the difficulty many people have moving from procedural programming to thinking in object.
"Java passes everything by value. There is no getting around that fact. "
Paul Clapham wrote:
Shawn Lau wrote:A reference isn't an object. Its an address of an object. No amount of philosophy is going to change that fact.
Abstractly speaking a reference is an "address" of an object. But it may or may not be implemented as a 32-bit (or 64-bit) quantity which contains the actual memory address of the object; it may be more complicated than that, for example to support garbage collection. It's entirely up the writers of the JVM to make that decision. But yes, from the abstract point of view a reference is an address.
Hopefully you don't consider an abstraction to be "philosophy". It's a very important tool in the design of computer languages and demanding to know how things actually work inside the abstraction is not especially useful when trying to understand modern computer languages.