On this page I collect some of the information I found useful as an Ada newcomer. May be you will find it helpful to get started with Ada.
Warning: This page is no longer actively maintained and might be out of date.
There are hundreds of different computer languages available, and around two dozen of those are more widely known and supported. However of those, only six are really widely supported on many different platforms by a range of high-quality development tools and are ISO standardized (or about to be) and can therefore be trusted for a long-term investment of work: C, C++, Ada, Pascal, Java, Fortran, COBOL. Fortran is optimized for number crunching and COBOL is a legacy language for systems that caused Y2K troubles. I am very experienced in C and quite experienced in Pascal, but both languages are now rather old and lack support for modern software engineering techniques (object-oriented programming, exception handling, multi-threading, templates, etc.). Other newer languages like C# and D look promising for the future, but there is no support infrastructure available for them yet.
This leaves C++, Ada, and Java as the modern languages. Although C++ is very widely used today, it seemed not to be suitable compared to the other two. C++ inherits from C the pointer arithmetic and problems associated with it, especially the fact that any code can easily overwrite any part of the data segment of a process, which means that private components of objects are not protected against accidental access in any way. This is a very significant problem for formal correctness evaluation of C++ problems, which is why standards for safety critical software do not allow C or C++ to be used in really critical applications. Both Ada and Java provide real object protection and do not use the dangerous pointer arithmetic (although Ada allows unchecked memory access for device-driver development). In addition, both Java and Ada have learned from C++ to avoid the complicated semantics of multiple inheritance and provide alternative simpler structures.
C (and for the same reason C++) is much less portable than Java and Ada. The C standard was written with many old legacy systems in mind and leaves many aspects of the language implementation dependent, while Java and Ada both define many implementation aspects much stricter. For instance, in C the character set is left undefined, while Java uses Unicode and Ada uses both ISO 8859-1 and Unicode. Both Ada and Java treat multi-threading as a part of the language and therefore can offer object synchronization, while C++ leaves multi-threading to the operating system API.
Although Java is handled in the trade press currently as a much more sexy subject than Ada, I have selected Ada in favour of Java. The main reason is efficiency. Java was designed to be used on byte-code interpreters, which execute code typically around 40 times slower than native machine code. Ada was designed to be compiled into efficient native machine code, but there are now also Ada compilers for producing Java byte code available. The performance and code quality of code from Ada compilers seems to be fully comparable with that from C++ compilers. In contrast to Java but like C and C++, Ada is a real systems programming language. Ada has excellent support for bit fiddling, interrupt handling, memory mapped hardware access, inclusion of assembler code, implementation of device drivers, and whatever else you need to write for instance an operating system. Ada's support for low-level hardware access is even better than that of C; for instance the memory layout of records is strictly defined, while bit-field layouts in C are left implementation dependent, and integer types with specified bit size as well as the rotate machine instructions that are missing in C are all available in Ada.
Another advantage of Ada is that a very comprehensive compiler validation test suite with over 3000 test programs exists. Every compiler vendor who wants to sell an Ada compiler to the U.S. DoD or one of its contractors must first pass this validation test. Basically every sentence in the Ada standard is covered by one of these test cases. The thoroughness of the Ada compiler validation procedure has ensured that there exist practically no bad Ada compilers on the market. This has made Ada popular with developers on somewhat more exotic hardware platforms (for instance digital signal processors), where the available C compilers frequently lack the quality of the major PC and workstation compilers, but where the Ada compilers are of fully comparable quality. There also exists a nice Ada Compiler Evaluation System (ACES) that allows developers to quickly assess the performance of an Ada development environment in great detail. This existing tool infrastructure is particularly useful for developers of mission-critical applications.
Ada was originally developed in the early 1980s (now known as Ada83), but the Ada used today has been significantly improved by a second revision of the standard that was published in 1995. Ada95 has for example many new mechanisms for object-oriented programming and new excellent facilities for interfacing with C functions. Ada95 is designed to be compiled together with modules written in other programming languages such as C, so it can be used easily in a mixed-language environment.
Ada was in the 1980s and early 1990s mostly ignored at universities, first of all because the available development tools where either of low quality or very expensive. Today, there exists a freely available production-quality GNU Ada compiler (GNAT) that uses the same portable code-generation back-end as GNU gcc together with the usual range of development tools (Ada modes for emacs, gdb, etc.) under Unix and Windows NT. With GNAT, we have now a development environment for Ada95 available under Linux that is as sophisticated and comfortable as that for C++. Ada95 has started to become a popular teaching language for courses in algorithms and data structures, software engineering, and real-time programming at many universities.
I have used Basic, Assembler, Logo, Pascal, C, Fortran, C++, Java, and Scheme before, therefore learning Ada95 ment for me just learning a new language and not learning how to program from scratch. Learning a new language is always fun. It took me less than two weeks to read John Barnes' Ada95 textbook and to get familiar with some of the chapters in the Reference Manual. After this I spent one week doing a few smaller programming exercises and then I felt comfortable with the language and could start to write production-quality source code. Of course, it will take some months to get really familiar with all the more rarely used parts of the language, but I don't think a good C++ programmer will need more than three or four weeks to get reasonably fit in Ada95.
Programming in Ada feels much more like programming in Pascal than
programming in C. I believe Pascal programmers will get somewhat
faster comfortable in Ada than C programmers, because of the
similarity of the syntax and type systems. A major change from C is
the lack of both pointer arithmetic and the preprocessor, however it
turns out that the Ada array and pointer mechanisms are much more
sophisticated than those of C and C++. For instance, untyped library
functions in C such as
have been made redundant by Ada's type-safe aggregate and array slice
mechanisms: Instead of
in C, an Ada programmer just writes
memcpy(a+5, a+10, 3*sizeof(*a))
to get the same machine code (if memcpy was an inline function in C).
a(5..7) := a(10..12);
The strong typing system in Ada sometimes gives the language a somewhat bureaucratic touch until you get used to it. For instance, conversions between Float and Integers or Unsigned_32 and Unsigned_64 have to be written down explicitly in Ada, but considering the many times I made the mistake of forgetting at which place C inserts such automatic conversion, this might turn out to be a useful feature. The best tip is probably that you should try to use the type system for your purposes and not try to work against it. This requires some practice, but the resulting code usually looks much safer and clearer.
It is important to understand that Ada is more concerned about the reader than writer of source code. A number of notational abbreviations that C/Perl/APL programmers love are missing in Ada, but the result is that Ada programs are usually much nicer to read later. Ada aims more at long-living, robust, correct and maintainable software. For rapid prototyping and quick hacks, you might prefer special languages such as Perl, Python, or APL.
Many aspects of Ada make it significantly easier to proof certain properties of your code. For instance, in a for loop, the loop variable is declared by the loop statement and it is handled as a constant inside the loop. So no matter how complex the code inside a loop is, you'll always know by looking at the loop statement how often it will execute and you can be sure that the loop will terminate. In C on the other hand, you have to inspect all the code inside the loop to make a similar conclusion. The Ada for loop can also much easier be compiled into code that uses the zero-overhead looping registers found in modern DSPs. There are many other aspects of Ada which should make code inspection and debugging much simpler than it is with C and C++, which adds to the suitablility of the language for safety and security critical applications. For very safetly critical applications (medical equipment, avionics, nuclear power plants, etc.), a special high-assurance subset of Ada called SPARK has been defined.
First of all you need a good textbook to learn the language. A few widely recommended ones are:
There are many others, but make sure you do not buy one published before 1995 that describes the old Ada83 language. You can also start to learn Ada by reading one of the very good online Ada tutorials. I first learned Ada 95 by reading Barnes, because the 1133 pages of Cohen's book frightened me a bit, but I now find that Cohen gives a clearer and more complete description of the language and I now usually refer to Cohen and the RM when I have questions about Ada, which helped to clear up some of the missunderstandings (especially about memory management) that I had after reading Barnes shorter book.
In addition, you should have a copy of the Ada ISO standard, also known as the Ada95 Reference Manual. It is freely available online but if you prefer to have a paper version nearby as well:
For Linux, just get the following files (most better Linux distributions come with a preinstalled GNAT anyway):
Alternatively, you can also use the extended RPM packages provided by the Ada for Linux Team. These come with many additional libraries preinstalled and use shared libraries for the runtime system (to avoid "Hello World" getting >50 kb large due to static binding).
GNAT is written in part Ada95 and part C. This means you will first have to install a precompiled version before you can compile it yourself from the GNAT 3.11p source code (just like it is with your C compiler). It is nevertheless a good idea to get the source code, because it is a good example of a very large Ada95 program, and its comments contain a lot of useful documentation.
First of all, you can do in Ada anything you can do in C, because
you can link Ada programs with C libraries and you can easily call C
functions directly using
pragma Import(C, ...); and the
Interface.C package. See the Reference Manual Annex B for
how this is done.
Just like the POSIX.1 standard defines the Unix C API, there exists also a POSIX.5 standard that defines an Ada API for Unix-like operating systems. You can either call the POSIX.1 C functions from Ada or the POSIX.5 functions which give you a much more Ada-typical interface to the operating system. The POSIX.5 standard
can be ordered from IEEE Publications, phone +1-732-981-1393 (1-800-678-IEEE), fax +1-732-981-9667, or from IEEE Computer Society Publications, 10662 Los Vaqueros Circle, PO Box 3014, Los Alamitos, CA 90720-1264, USA, phone +1-714-821-8380, fax +1-714-821-4010.
GNAT comes only with the libraries defined in the Ada standard. If you want to use the POSIX.5 native Ada interface, get the FLORIST package, a POSIX.5 library for Linux and some other Unices by Ted Baker from Florida State University.
Many popular C libraries come now with an Ada binding, for instance:
You should definitely have a look at
Other potentially useful things I ran into:
In Association with Amazon.com.
created 1998-03-13 – last modified 2000-03-08 – http://www.cl.cam.ac.uk/~mgk25/ada.html