Re: What computer language is used a lot in the IT industry?

From: Gerry Quinn (gerryq_at_DELETETHISindigo.ie)
Date: 07/01/04


Date: Thu, 1 Jul 2004 09:47:12 +0100

In article <dxLEc.25055$Xn.20344@nwrdny03.gnilink.net>,
tgm2tothe10thpower@replacetextwithnumber.hotmail.com says...
> Gerry Quinn <gerryq@DELETETHISindigo.ie> coughed up the following:
> > In article <o9CEc.23061$Xn.9403@nwrdny03.gnilink.net>,
> > tgm2tothe10thpower@replacetextwithnumber.hotmail.com says...

> > In Java, what is passed is a reference to something to which exactly
> > that can be done.
>
> That doesn't have anything to do with the reference itself!

I know - the irrelevance of the reference itself is exactly what I've
been pointing out!

> > Passing this reference is the only function of the
> > passed parameter, which is why the passed parameter is called a
> > 'reference'. The compiler writer may be interested in the value of
> > the reference per se, but nobody else is.
> >
> > What do we pass? A reference. So how are we passing? By reference,
> > obviously!
>
> Nope.
>
> Ok, let's break this down.
>
> "Passing A" idicates that /something/ is going to be passed
>
> "Passing BY" indicates the /way/ that something is going to be passed.
>
> What do you pass? A reference.
>
> How was it passed? BY VALUE.

I understand the argument perfectly well. But the point is essentially
a useless one - the reference or pointer or whatever is just a tool I am
using to do a job which is to pass something about what the reference
refers to. To say 'Java passes by value' is to impoverish our ability
to speak of what we want to do in a Java program. At least be specific
when you say "Java passes by value" and point out that you are referring
to how "Java passes references by value", or "passing the value of the
position of a sentence describing how Java passes references by value",
as you would no doubt prefer to say!

> > Therefore, since all languages pass something by value (at least from
> > the point of view of the language), the only distinction of interest
> > is whether they can pass by reference as well. The natural
> > distinction is whether they pass a copy of the relevant data, or a
> > reference to the relevant data, or both. And Java falls in the
> > second category.

You don't answer this point. Since something is always passed by value,
what is the point in saying a language "passes by value" when you mean
it in a sense in which ALL languages by their nature "pass by value".

> > In short, to say a language "passes by value" is to elevate a useless
> > distinction to a position where it merely confuses the issue.
>
> Gerry, please look at these sites:
>
> http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html:
>
> "Q: If Java uses the pass-by reference, why won't a swap function work?
> A: Your question demonstrates a common error made by Java language
> newcomers. Indeed, even seasoned veterans find it difficult to keep the
> terms straight. Java does manipulate objects by reference, and all object
> variables are references. However, Java doesn't pass method arguments by
> reference; it passes them by value."

It is confusing because the terminology is pointless, suited only to
compiler writers. To pass references by value is to pass the things
referred to by reference. Spelling out that "Java passes references by
value" is okay, because we can separate both senses of the word
'reference'. Clearly, Java teachers, along with their language, have
created a generation of confused programmers. If your terminology
confuses everyone, why do you insist on using it, without even spelling
it out?

Explaining matters in terms of aliasing would be better. That way you
are not using terms that seem designed to confuse.

>- Gerry Quinn



Relevant Pages

  • Re: The Java no pointer big fat lie!
    ... > reference types, it wouldn't be a good comparison. ... and what you can't - and there is a big difference in Java to C and C++. ... You cannot change it in the language itself, ... Thus I would distinguish pointers from ...
    (comp.lang.java.programmer)
  • Re: Why C# and Java have got it wrong
    ... there are GC languages other than Java. ... > you used any language which conveniently supports higher order functions ... and I must apologize: garbage collection is ... > a reference to the proxy object living on the stack. ...
    (comp.programming)
  • Re: call by reference
    ... but if saying "Java has call by reference" makes ... >user of the language shouldn't really need to know how the language is ... but I know that many things about Java made more ... perfect sense. ...
    (comp.lang.java.programmer)
  • Re: pass by reference
    ... talking about Java, that it does when talking about other languages. ... this is also true for "reference" itself. ... Because one "reference" is an object reference, ... This is natural language as I understand it. ...
    (comp.lang.java.programmer)
  • Static typing [was: Benefits of compiler errors]
    ... Java is not statically-typed, but the existence of null is the easiest one to pick one. ... language, which means that every variable and every expression has a type that is known at compile time. ... The null reference can always be cast to any reference type. ... as an authority on type theory, ...
    (comp.lang.java.programmer)