Section 16.8 - Ada language vs. Java language
It makes sense to close a discussion of Ada and Java by comparing the two
Ada and Java have more similarities than differences. Both the Ada language
and the Java language were designed with safety in mind
(both support strong typing, omit pointers, and perform many compile-time
and run-time checks).
Both support an object-oriented approach based on a single
When generating class files,
both Ada and Java support garbage collection, multitasking,
graphical user interfaces (GUIs).
There are differences, of course. Here are some technical advantages of
the Ada language over the Java language
has a similar list):
- Ada supports enumerated types.
- Ada supports operator overloading for infix operators (for example,
you can define an infix + operation for complex numbers).
- Ada supports generics. There is no Java equivalent, though
Java's "Interface" and its root Object class can
sometimes be used to do similar things.
- Ada supports "in", "out", and "in out" to document the use of parameters,
and these modifiers work on both tagged types and scalars.
- Ada is easier to read in some cases (compare "and" with "&&";
compare "for I in 1..10" with "for (i=1; i <= 10; i++)";
compare "a=b" with "a==b").
- Ada permits array boundaries to start with any scalar. The Java language
requires array boundaries to start at 0, a common source of "one-off" errors.
- Ada supports numeric range checks more specific than the built-in types.
This can be used to detect errors that Java doesn't.
- Ada supports method calls using named and unordered parameters,
and supports default parameter values.
- Ada supports subprogram access types and nested subprograms.
Java has some technical advantages over Ada, too:
- Java supports "interface" types.
There is no standard Ada equivalent, though
Ada generics and the nesting of objects
can sometimes be used to do similar things.
Ada programs that generate Java code can use and define Java interfaces,
using a special pragma to do so.
- Java permits specifications to be circular (A depends on B which depends
on A), while Ada does not. There is some argument that this is a disadvantage,
since circular references can indicate poorly structured systems, but in
terms of ease-of-use this is an advantage.
- Java class definitions tend to be shorter than Ada.
Here are some of the reasons for this:
Ada enforces a distinction between objects and access values
This causes definitions to be longer (for example, in Ada you have to define
X_Obj and X_Ptr types everywhere, while all of that is not used
in the Java language).
Ada requires an explicit list of all classes used ("with" statements) in a
class being defined.
Java does not require a list of classes used; the closest Java has is
its "import" statement, which is like the "use" clause in Ada.
Java has an implicit "this" parameter for non-static methods; Ada requires
all parameters to be explicitly listed.
Java interfaces have to be handled using a somewhat clumsy Ada syntax.
- Java supports hierarchies of exception definitions. Java also includes
of exceptions that might be thrown (raised) by each method as part of the
Naturally, more than technical issues make a decision. Here are some other
issues regarding the use of the Java language and Ada language for creating
Java applets and applications:
- There are a number of tooling issues.
At the time of this writing
there are more Ada compilers than Java compilers, but by the time you read
this there should be many compilers for both languages.
Most Ada compilers
generate native (high-speed) code that can take advantage of the underlying
hardware, while Java compilers are just beginning to appear.
only one Ada compiler can generate class files and applets, so the quantity
of compilers tilts towards Java
if you're solely interested in generating applets and/or class files.
You'll also need to compare the tool capabilities themselves: which have
better interactive development environments (IDEs)?
Which have additional functionality (like user interface generators) that
Since just-in-time Java compilers that take class files can compile both Java
and Ada class files, the choice of language is irrelevant
for just-in-time compilers.
- There are large reusable component libraries for both languages, each with
Compare the relevant reusable components
in the different languages for your application.
- There is an ISO (international) standard for Ada, while a standard for Java
is probably many years away (at the time of this writing).
- There is a large standard test suite for Ada compilers; none yet exists
- There are sometimes vendor restrictions prohibiting use of the
for safety-critical systems; Ada is commonly used in such areas, and compilers
can be bought without such prohibitions.
- The use of
in real-time applications is somewhat currently a research area,
while Ada is already used in such areas and has been for many years.
- Most Java materials and tools assume that users are using
the Java language.
Thus, if you're developing a Java application in Ada you'll need to
learn the translation conventions (as discussed in previous sections) and
be able to make such translations mentally.
No such translations are needed if you're using the Java language.
Which of the following statements is true?
- The Java language lets you write your own infix operators, while
the Ada standard supports interface types and hierarchical exceptions.
- A web browser that includes a just-in-time compiler for class files
can't compile programs written in Ada.
- When generating Java class files, both Ada and Java support
garbage collection and a standard graphical user interface.
- Statement 1.
- Statement 2.
- Statement 3.
You may also:
David A. Wheeler (email@example.com)
The master copy of this file is at