LISTSERV mailing list manager LISTSERV 16.0

Help for TEAM-ADA Archives


TEAM-ADA Archives

TEAM-ADA Archives


TEAM-ADA@LISTSERV.ACM.ORG


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

TEAM-ADA Home

TEAM-ADA Home

TEAM-ADA  September 1998

TEAM-ADA September 1998

Subject:

Clarification: Ada/Java

From:

"W. Wesley Groleau x4923" <[log in to unmask]>

Reply-To:

W. Wesley Groleau x4923

Date:

Thu, 17 Sep 1998 11:24:12 -0500

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (252 lines)

The friend I quoted yesterday sent me a better representation of his
views.  I apologize to all of you for not checking with him before quoting
him.  The following is that better representation, except for my questions
or comments which have an _even_ number of '>':

** (If you're not interested in most of this, you still might want to
scroll down to the part about "subtypes") **

> The "Purity" Measure
> ====================
>
> In my original comments I said Java was better than Ada because Java was a
> pure OO language while Ada95 (and C++) were hybrids.
>
> > Some folks would say Ada-95 offers the best of both worlds and C++ the worst.  :-)
>
> If I had to choose between Ada95 and C++ I would certainly choose Ada95.
> Stroustrup is a genius but even a genius couldn't make C into a decent OO language.
>
> When I used Ada95 I did feel it was the best of both worlds. I felt that in
> many situations an OO approach was not beneficial and it was nice to have a choice.
>
> OO purists would say that Java isn't a "pure" OO language. And it is certainly
> possible to write non-OO code in Java; just make all your methods static.
>
> Conclusion: Java and Ada aren't really so far apart here after all. But I
> still give Java a slight edge on the "purity" scale. If "purity" sounds too
> subjective (and thus irrelevant) call it "consistency and ease of use."
>
> Dynamic Class Loading
> =====================
>
> > Many Ada fans (and myself) agree, except that dynamic loading is (1) a feature of
> > the JVM, not the language, and (2) has been available in Unix for years, but
> > never taken advantage of.
>
> Well, help me here. In Java, I can create an object at run-time whose class
> didn't even exist at compile time. For example, I can prompt the user for a
> String and then use that String as an argument in the Class.forName method.
> Once I have the the Class object, I can call its newInstance method. I believe
> the technical term for this is "Way Cool". That seems like a language feature
> to me but I realize I may be missing something.

Conceded.  I was not aware of these Java features.  And I think I would
use the same technical term.  You can do that in other languages, but it's
certainly not easy.  (I was once asked to work on a "Database Management
System" which I discovered was a BASIC program that queried the user for
names, types, and constraints of data fields, generated another BASIC
program, and CHAINed to it.  Ugggh!)

> Garbage Collection I
> ====================
>
> > Real-timers are divided on garbage collection.  In Ada, all garbage
> > collection is automatic for what Java calls "primitive types".
>
> This is true of Java as well. Java primitive types are the types that are
> handled like types in non-OO languages.

I didn't mean to imply that it wasn't true of Java.  Both of them reclaim
stack on exit of scope.  The difference is that Java limits it to a small
set of non-OO types while Ada does it for everything not explicitly put on
the heap.

> > And for a
> > heap-based type, one can define the garbage collection in the package that
> > declares the (controlled) type, making it automatic for all clients.
>
> I concede that Ada offers much more flexibility here. This goes back to the
> trade-off between language "size" and language features.
>
> Wacky C Syntax I
> ================
>
> > > * The economy of expression afforded by expression statements and the lack of
> > > "end" statements in Java is easy to misuse but _can_ be used to advantage
> > > also. Ada is a bit stilted.
> >
> > I find no advantage in writability over readability.  However, with familiarity,
> > the readability problem probably fades considerably.
>
> I suspect that objective observers would give this point to Ada. Writing
> "C-style" code is a guilty pleasure, I guess.

And as I hinted, most languages are perfectly readable to their experts.
APL and some C may be exceptions. :-)

> Pandering to the Masses
> =======================
> >
> > > * The biggest non-technical advantage of Java is that it is available! This is
> > > because Sun has downplayed the innovative features of the language and sold it
> > > as an improved C.  I think Java is much better than that but Sun was clever
> > > enough not to stress it.  Ada got that wrong from a marketing point of view.
> > > Ada bills itself as the language for doing software right, but, guess what,
> > > nobody wants to do software right!
> >
> > I almost agree.  Few people [not 'nobody'] want to "do software
> > right"  As one of those few, I still like Ada better than Java (and
> > I wish I had occasion to learn Eiffel).
>
> Specifications compilable before implementation
> ===============================================
>
> You and I agree this is deficiency of Java. Now that I think of it, though,
> you can achieve a similar effect in Java with abstract classes and with
> interfaces. But Ada's compilable specs are a simple, powerful, proven
> language feature that the rest of the world will eventually have to recognize.
>
> Enumerated types, non-Zero-Based Array Indices
> ==============================================
>
> We basically agree that it would be nice if Java had these.
>
> Garbage Collection II
> =====================
>
> Certainly Ada is more flexible here. And in real-time applications Ada's
> advantage can be significant.  If I was doing an embedded real-time project
> with demanding timing and/or memory requirements, I would certainly be ready
> to go back to Ada95!
>
> Object Equality
> ===============
>
> > I find it rather non-intuitive and awkward that in most cases, assignment
> > and comparison operators relate to the references, not to the actual
> > object or value.  The rarely needed operation is the easiest to read and
> > write, while the common one is more awkward and often doesn't even exist
> > until defined by the programmer.  Apparently the author of my Java book
> > thinks so, too.  It's also a readability problem that you have to think
> > about whether the types are "primitive" to know which of two meanings to
> > read for an operator.  This is contrary to Java's argument against
> > operator overloading!
>
> As a teacher of Java as well as a user, I agree this is an unfortunate
> confusion in Java.  Of course it all makes sense once you get used to it,
> but I guess that's what people say about C and C++ wacky features.
>
> Wacky C Syntax II
> =================
>
> > Not possible to "forget" to put "break" in a case statement.
>
> > > I agree that this is an amazingly stupid C characteristic not fixed in Java.
>
> Subtypes [READ THIS ONE!]
> ========
>
> > Types and subtypes whose ranges relate to the abstraction, not to the
> > implementation.  (Can do it in Java, but only with a lot of OOP
> > baggage.)
>
> Ya know, a lot of what we're saying here has been said a million times already
> and I'll bet a lot of people stopped reading this message paragraphs ago...
> _but_ I think this issue of subtypes deserves some real attention.
>
> I used to be a big believer in subtypes and I couldn't understand how C
> programmers lived without them. But I saw subtypes get really abused on a
> large Ada project and now I don't know what to think. I'd like to hear some
> other opinions.

I must confess that much of the Ada code I've seen has been written by
people without adequate Ada training.  My viewpoint is teach people how to
use the feature instead of forbidding it--but then, that's what C fans say
about Ada!  :-)

> Fixed sizes for primitive numeric types
> =======================================
>
> > > As for int being 32 bits, that's tied to small and simple again.  I thought it
> > > was a daring, bold, and positive move for Java to just _decide_ that ints were
> > > such-and-such a size, period.
> >
> > This was definitely a good idea for C programmers who insist on writing
> > size-dependent code even though they know it's not portable.  On the other
> > hand, if you write in terms of requirements or abstractions (as Ada
> > allows), your code is portable to any compiler that supports the ranges or
> > other details that you've specified--and other compilers won't compile
> > it!
>
> Operator overloading
> ====================
>
> > Since Java does not allow putting range constraints on primitive types,
> > anyone who wants it has two choices:
> >   a. Explicitly write your range checks everywhere you do anything with the type.
> >   b. Write a class that always does it's own range checking, and give up
> >      infix notation for your expressions.  A * B + C * D  becomes
> >      Sum_Of(Product_Of(A,B),Product_Of(C,D))  Plus you have to write all
> >      the operators your clients might need--even though the comparisons
> >      need no range checking.  This is one spot where the philosophies are
> >      reversed:  Java takes away a valuable capability because programmers
> >      abused it.  Ada allows it even though there's no way to force the
> >      programmer to give the operator the "intuitive" meaning.
>
> Yes, well, I hear you.
>
> Access-to-subprogram that is fully type safe and nesting safe
> =============================================================
>
> > the inventors of Java AND of Ada 83
> > rejected access-to-subprogram because it wasn't safe.  But in Ada 95, so
> > many people demanded it that we figured out a way to MAKE IT SAFE.  Java's
> > inventors either didn't know this could be done, or they thought it would
> > make the language "large."
>
> I know Ada95 has type-safe procedure references (oops, I mean accesses!). But
> I don't think Java has a problem here.  In Java, procedure references are
> "passed" by using interfaces.  I think it's type-safe, but help me out here.

You're probably right.  I haven't gotten to "interfaces" in my book, so I really
don't (obviously) understand them.  Something earlier in the book suggested that
Java "rejected access-to-subprogram because it wasn't safe." (not in those terms)

> Tasking
> =======
>
> The usual points...
>
> The OOP inheritance mechanism is independent of the encapsulation mechanism
> ===========================================================================
>
> >  (Lack of this is why C++ had to have the dangerous
> >  "friends" feature.  Does Java have something like that?)
>
> I had written:
> > > Actually I think Java and Ada are tied on this one. Java packages are
> > > independent of inheritance.
>
> > I don't know what the connection is.  I was referring to the fact that two
> > Java classes cannot share private data like two or more Ada types in one
> > Ada package.  In Java, the methods and instance variables are encapsulated
> > within the class, which corresponds to ONE Ada type as well as ONE Ada
> > package.  This is not major, though, since mutually dependent types are
> > not that often needed and Java does have some workarounds.
>
> I still think Java has this covered.  Non-public classes and methods I declare
> in a Java package are only visible within the package.  Java programmers don't
> think this way but it _is_ a natural use of Java packages to put two public
> classes in a package along with all kinds of non-public classes.  Nobody
> outside the package would be able to access the non-public classes.  I don't
> think this is a "workaround"; I think it's a significant Java language feature
> intentionally provided to give Java programmers the same capability that is
> available in Ada.  It's just that most Java programmers don't understand the
> _advantages_ of this kind of encapsulation.

I guess I'll have to wait on this one till I finish the Java book.
I don't know anything about Java packages.  I was basically parroting
the complaints I had heard from others that you can't easily have
mutually-dependent data types in Java.

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

December 2017
November 2017
October 2017
September 2017
June 2017
May 2017
April 2017
January 2017
December 2016
November 2016
October 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
December 2010
November 2010
October 2010
September 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
June 2007
May 2007
March 2007
February 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
January 2001
December 2000
November 2000
October 2000
September 2000
August 2000
July 2000
June 2000
May 2000
April 2000
March 2000
February 2000
January 2000
December 1999
November 1999
October 1999
September 1999
August 1999
July 1999
June 1999
May 1999
April 1999
March 1999
February 1999
January 1999
December 1998
November 1998
October 1998
September 1998
August 1998
July 1998
June 1998
May 1998
April 1998
March 1998
February 1998
January 1998
December 1997
November 1997
October 1997
September 1997
August 1997
July 1997
June 1997
May 1997
April 1997
March 1997
February 1997
January 1997
December 1996
November 1996
October 1996

ATOM RSS1 RSS2



LISTSERV.ACM.ORG

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager