Interesting exchange between an Ada-phile and a former Ada-phile who's
"converted" to Java.  Not intended as flame-bait......

----------------------------------------------

> * Java is a small language (not necessarily an advantage, but certainly a difference)
> * Java is "pure" OO. This is probably the biggest technical advantage of Java
> over Ada. A hybrid language like Ada95 or C++ tends to be the worst of two worlds.

Some folks would say Ada-95 offers the best of both worlds and C++ the worst.  :-)
(Some say Smalltalk is better than Java because _Java_ is a hybrid!)

> * The built-in support for dynamic class loading and the automatic garbage
> collection are inovative, creative, powerful, and useful technical advantages
> of Java over Ada as well.

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.

Real-timers are divided on garbage collection.  In Ada, all garbage
collection is automatic for what Java calls "primitive types".  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.

> * 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.

> * The biggest non-technical advantage of Java is that it is available! This is
> because Sun has downplayed the inovative 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 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).

> > To me, the list of disadvantages begins with:
> >
> > 1. Specifications compilable before implementation.
> >
> >    a. A well-written Ada specification is (except for fancy typography)
> >       what you get from javadoc IF you put the required special-format
> >       comments in.
>
> I agree this is a serious deficiency of Java.
>
> > 2. Enumerated types
> >
> >    a. Using them as array indices
>
> I agree this is also a serious deficiency of Java.

Although I can understand it.  Java is based on C where
the enumerated types are just integers in disguise.

> > 3. Arrays that don't have to start at zero.
>
> This is tied to Java being small. We can't have everything and have small too.
>
> > 4. Objects don't have to be primitive to be on the stack - more efficient
> >    garbage collection.
>
> I don't understand this one.

I should have worded it differently.  In Java, "primitive types" are
numbers and booleans--things that are small.  These and only these go on
the stack and have immediate automatic garbage collection.  By immediate,
I mean after a routine returns, all its stack data is reclaimed on the
very next call instruction.  Heap-based objects, which are all objects in
Smalltalk and all but "primitives" in Java are garbage-collected when the
collector is triggered.

In Ada, you are "forced" to _decide_ when to use the heap.  But since you
only use the heap when you need it, most of the time you are not "forced"
to remember "this object is not primitive, so I have to use 'new'"  When
you decide to use the heap, Ada does not force you to have
garbage-collection.  But it does provide you with a mechanism (controlled
types) to guarantee the garabage collection is reliable.

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!

> > 5. 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.
>
> > 6. 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.)
>
> After BSY-2, I wonder if programmers are smart enough to handle subtypes.
>
> 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!

> > 7. Operator overloading
>
> Lots of pro's and con's here. I miss it but I think maybe I really am better
> off without it.

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.

> > 8. Access-to-subprogram that is fully type safe and nesting safe.
>
> I'm not trying to spin you up and I'm not trying to be cynical--my whole
> world-view has honestly changed. People don't _want_ a foolproof language and
> I'm not going to waste another second of my life being upset that they don't.

I command your pragmatism.  I am _trying_ to learn not to waste time that
way.  :-)  On this point however, 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."

> As Lincoln said: "God must have loved the common man; He created so many of
> them." I'm serious here. The biggest problem with Ada is that it tries to do
> things right and most people don't want to be forced to do things right.
> Please don't reply by saying Ada doesn't "force" you... I just mean the
> software profession truly is not ready to embrace the concepts of
> responsibility, correctness, etc. It's too bad, but Java is "better" because
> it is more in tune with the way programmers _are_ today. Let's give it credit
> for being at least a tiny step forward from current technology: C and C++! I'm
> saying Ada is _too good_ for the industry.

I honestly am happy Java is reducing the amount of C and C++ hacking.  But
I don't quite agree that "Ada is too good".  Many companies were finally
starting to take Ada a little more seriously as the shortcomings of C and
C++ became more apparent (and more costly), and as the empirical evidence
of Ada's cost-effectiveness.  Others have adopted Eiffel for the same
reasons.  The appearance of Java with its in-between position weakens that
trend.  Still, it *IS* an improvement for thousands of programmers.

> > 9. Tasking mechanism is higher level (more abstract) and simpler than
> >     Java's Runnable methods.
>
> Yes, but Ada tasks are also _too_ high level for a lot of applications.

True.  For this reason, most Ada vendors offered semaphores all along.
And the new "protected" types are suitable for (and simpler and safer
than) most of the things semaphores were used for.

> > 10. Protected types can do more than Java's synchronized methods, and
> >     there is no way to bypass a protected type's synchronization
> >     mechanisms.
>
> Back to small and "forcing" people again.

Well, I wasn't really thinking of "forcing" people.  I haven't studied
synchronized methods yet, but I've been told that synchronization is
guaranteed only if all clients call _only_ the synchronized methods.
Here, it's not Ada that does the "forcing." it's the programmer that
"forces" synchronization on his clients by making the type protected.  In
Java, it is much more difficult for the designer of a class to prevent his
clients from unsafe use.

> > 11. 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?)
>
> 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.