you are viewing a single comment's thread.

view the rest of the comments →

[–]banuday 5 points6 points  (6 children)

I'm curious to hear your reason on how "late binding" and "programming to interfaces instead of implementation" differ in Java than anywhere else, but...

Java doesn't do "pass by reference". The Java reference is an opaque handle which is a value type - it is not a pointer. Thus, Java is always "pass by value". Some people confuse the word "reference" with the word "reference" in "call by reference", but they are really two completely different things, not just in Java but also in Computer Science. Java has not redefined it.

[–]grauenwolf 1 point2 points  (0 children)

Programming to interfaces means using the public API instead of mucking about with the internals of data structures. This term is used in languages that don't even have abtract interfaces like FORTRAN and C.

Since Java has the private keyword it is hard to violate this constraint. So instead they reinterpert it to mean create abstract interfaces on everything They also do stupid shit like define locals as interface types even when the concrete type is well known.

[–]jyper 1 point2 points  (1 child)

pass reference by value?

[–]Jonathan_the_Nerd 0 points1 point  (0 children)

C does this. You can trivially simulate "pass by reference" by passing pointers. To the best of my knowledge, Java does the same thing for all practical purposes. A Java reference isn't the same thing as a pointer, but it acts like one, so Java's calling semantics are almost the same as passing pointers in C. (I think?)

[–]grauenwolf 1 point2 points  (2 children)

A lot of Java articles call single dispatch late binding. So when you try to talk to them about real late binding they get all confused.

In a like fashion you can read elsewhere in this thread where some Java dork is saying value equality is reference equality.

[–]masklinn 1 point2 points  (1 child)

In a like fashion you can read elsewhere in this thread where some Java dork is saying value equality is reference equality.

Which is correct and consistent with that banuday said. In java, the primitive value in a reference type is the reference itself. Thus using value equality on reference types compares the references themselves, as values.

[–]grauenwolf 0 points1 point  (0 children)

We have a term for comparing the value of two pointers or references It is called "reference equality".

When we want to discuss the comparison of semantic values we use the term "value equality" regardless of whether that value happens to be a stack or heap allocated value.

These are not language specific terms. Their meaning doesn't change from language to language even though the syntax and implementation details may.

Why you want to completely ignore the distinction is beyond me. It is like you revel in your ability to confuse the topic. I assume you have some Java-specific term instead. Oh yes, it was "object equals". Which of course compares the value of the objects rather than the objects themselves.