comp.lang.ada
 help / color / mirror / Atom feed
From: me@me
Subject: Re: Ada for numerics computation (i.e. forget Fortran ?)
Date: 1999/04/27
Date: 1999-04-27T00:00:00+00:00	[thread overview]
Message-ID: <7g4av3$bgd@drn.newsguy.com> (raw)
In-Reply-To: 7g1qcm$o4$2@pegasus.csx.cam.ac.uk

In article <7g1qcm$o4$2@pegasus.csx.cam.ac.uk>, mgk25@cl.cam.ac.uk says...
>

>The childish hype surrounding "Javajavajava" is what has most of all
>turned me a bit against this language. 

But hype sells !

I think the reason for Java popularity is that people in general were not
happy with C++ (too complicated, etc..) , and wanted a different OO 
language, and Java came at the right time, and it looked like C++ to 
keep the crowds happy.

One thing that I did not see many discuss about java, is its default use
of references.

What I do not like in Java, is that it is not 'value' based by default.

meaning, when I write (where A and B are objects):

A = B;

then I go and modify the value of object B in some other part of 
the program, this results in A's value also being modified.


This is a side effect of the fact that in Java, objects are references,
hence in the above assignment, A takes on the same reference as B, making
A and B references to the same 'object' data on the heap.

(In simpler terms, A and B point to the same object on the heap).

(this one time caused subtle a bug in one of my programs, when I started
learning Java, as I was used to value-based languages, untill I 
noticed this. I was 'saving' objects in a vector, then reading new values
into the source objects, but this was also causing the objects in the
vector to change indirectly).

To make A get its own value of the object B, one needs to be explicit and
write

A = B.clone();

(Assuming B supports the clone() method).

So, in Java, to get the value, you need to be explicit, else you get
the reference (pointer).

In Ada, (and C++), they are value based, i.e. the default in assignment
is to get the value of the object. If you need to get a reference, you
need to be explicit.

Some people might not consider this a big deal, and can get used to it
(as with LISP). For me, I find that I spend more mental energy while 
programming in Java for the above reason, to watch out for when I need
to use clone() or not. I do not have this problem with value based languages,
such as Ada.

What do you like more? or think is better, value-based assignments, or 
reference based?
(I assume you would prefer value-based if you are an Ada programmer).

me.





  reply	other threads:[~1999-04-27  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-23  0:00 Ada for numerics computation (i.e. forget Fortran ?) Hans N. Beck
1999-04-23  0:00 ` Gautier
1999-04-23  0:00   ` Gautier
1999-04-23  0:00 ` Markus Kuhn
1999-04-24  0:00   ` bglbv
1999-04-25  0:00     ` Edwin Guenthner
1999-04-25  0:00       ` bill
1999-04-25  0:00         ` Edwin Guenthner
1999-04-26  0:00         ` Jean-Pierre Rosen
1999-04-26  0:00           ` Edwin Guenthner
1999-04-26  0:00             ` Markus Kuhn
1999-04-27  0:00               ` me [this message]
1999-04-27  0:00                 ` Jean-Pierre Rosen
1999-04-28  0:00                   ` Edwin Guenthner
1999-04-28  0:00                     ` Jean-Pierre Rosen
1999-04-27  0:00                 ` Matthew Heaney
1999-04-27  0:00                   ` dennison
1999-04-25  0:00       ` Robert Dewar
1999-04-27  0:00 ` Joachim Schroeer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox