Elegance of Java and the Efficiency of C—It's Ada!
In his article “Comparing Java Implementations for Linux”, Michael Hirsch (LJ August 2000) searches for “a programming language with the elegance of Java and the efficiency of C”. This language already exists and it's called Ada.
The current version of Ada, Ada 95, is a revision of the Ada standard (Ada 83 was the original ANSI/ISO standard). It was standardized while C++ and Java were still in early childhood. Ada is often considered a bulky, antiquated language without the coolness of Java or the seriousness of C++. However, Ada is a powerful and modern language.
Ada has all the features of Java in addition to some of its own (such as generics and operator overloading. Actually, Ada provides all the features of Java and C++ (except for direct support for multiple inheritance) in one language, their web site (see Resources) provides a good comparison of the languages. You can even build j-code applets from Ada source. Thus, you have all the advantages of Java and more.
Ada is a strongly typed language which, if used correctly, can lead to less ambiguous code and more maintainable programs. The result is that errors can be detected easily at compile time instead of at debug time. More information on the Ada language can be found at their web site.
There are a number of Ada compiler vendors around, and you can get one for virtually any platform which, again, can cross-compile to (almost) any other platform. The most well known vendors are Rational, Aonix, R. R. Software and Green Hill Software (see Resources).
However, Michael Hirsch also wanted an open-source project. In reply, GNAT from Ada Core Technologies is to Ada as gcc is to C/C++, almost. GNAT is written almost entirely in Ada and uses the gcc code generator. The public version of GNAT (see Resources for site where you can download it) is distributed under the FSF copyleft license. ACT also provides a nonpublic version of their compiler under a support contract.
I have written the equivalent Ada program to Michael Hirsch's Java and C++ programs as shown in Listing 1. As you can see, the listing is highly readable and looks very much like both the Java and C++ program. It is divided into three units, a package specification (like the C header files), a package body and the main program (a procedure). Ada has specific rules concerning what goes in which unit, and GNAT enforces this by requiring each unit to be in a separate file, where the file name must be the package/procedure name postfixed with .ads for specification and .adb for package/procedure.
Listing 1. Ada Equivalent of Java and C++ Programs
You can type in the example (or download it) into one file and run the utility gnatchop, which is included in the GNAT distribution. This will split the file into the three required files with the respective filenames. To compile and link, you can use the specially modified GNAT version of gcc, but it's more practical to use the gnatmake utility. Just type: gnatmake perftest and gnat will compile the required units and then bind and link the main procedure.
Since I do not have the same hardware as the author, I have performed the same Java and C++ benchmarks, in addition to the Ada benchmark, on two Linux machines and a ten-inch Sun Ultra. The results are shown in Table 1; the elapsed time is objects per millisecond.
The Ada compilers used were Gnat 3.12p, Gnat 3.13p and JGNAT 1.0p (p = public). The latter two were just released at the time of this writing . Please note that there are other Ada compilers that produce executables that may run faster or slower than the GNAT compiler.
Table 1. Results of Ada, Java and C++ Benchmarks
JGNAT is a peculiar beast, as it compiles Ada code into Java byte-code which can, in turn, run on any JVM. As you can see, it is only about 15% slower than the SUN JDK and JRE 1.2.01 is actually faster! And that is for precisely the same code compiled with the GNAT compiler, using the very first version of the JGNAT compiler! This can only get better.
I tried running the JGNAT-compiled programs using kaffe on Linux, but got:
[ft@modesty jtest]$ ~/kaffe/bin/java perftest@bbKaffe: mem/gc-incremental.c:823: gcMalloc: Assertion <\#145>fidx < nrTypes && size != 0' failed.
This suggests a bug in kaffe.
A small note on Ada in general and GNAT in particular: By default, the compiler compiles in many of the runtime tests to certify that everything goes smoothly. Therefore, if there's a problem, it can make a controlled action to avoid premature program termination. Usually, the action is to raise an exception. The -gnatp disables many of these tests and, hence, makes the program run faster. I do not recommend doing this, but it does provide for a better comparison with the C++ speeds.
For this particular test, Ada is about 19% slower on average than C++. On the Sun platform, this is down to about 8% using a comparable code generator (GNAT uses gcc 2.8.1 as its base). Note that this is a very limited test, and it only goes to show that Ada can produce running speeds comparable to C++. In some cases, Ada will actually run faster than the C++ counterpart. My guess is that the difference will level out, perhaps slightly in C++'s favour. The usual disclaimer applies.
However, it is in development and, later, in maintenance that the real savings can be harvested with Ada. Refer to www.rational.com/products/whitepapers/337.jsp for a thorough comparison between Ada 83 and C.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?
- Readers' Choice Awards
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




3 hours 26 min ago
7 hours 2 min ago
7 hours 34 min ago
9 hours 58 min ago
10 hours 1 min ago
10 hours 2 min ago
14 hours 27 min ago
16 hours 18 min ago
21 hours 31 min ago
1 day 43 min ago