Getting started with ada
Remarks#
Ada is an internationally standardized, high-level, object-oriented computer programming language that supports strong typing and structured programming. More information may be found here.
Versions#
Version | Release Date |
---|---|
Ada 2012(TC-1) | 2016-04-01 |
Ada 2012 | 2012-12-10 |
Ada 2005 | 2007-01-01 |
Ada 95 | 1995-12-10 |
Ada 83 | 1983-01-01 |
Installation or Setup
Ada is a programming language for which there exists multiple compilers.
-
One of these compilers, and perhaps the most used, is GNAT. It is part of the GCC toolchain. It can be installed from several sources:
-
The yearly GPL release done by AdaCore, available for free on libre site. This version has undergone all internal testing that AdaCore does for its pro releases, is available on a large number of platforms. The compiler and its runtime are released under the GPL license, and, unless you are using no runtime, any executables you distribute will also be covered by this license. For academics and projects in their initial stages, this is not a problem.
-
The FSF gcc receives the same patches regularly. The version of GNAT might not be always up-to-date, but catches up regularly.
-
A number of contributors are packaging that FSF version for various Linux distributions (Debian-based systems, among others) and binaries for Mac OS X. Using the package manager from your distribution might be the simplest way to install GNAT. Such versions come with the standard GCC license, and allow you to write closed source code.
-
AdaCore also provides GNAT Pro, which comes with the standard GCC license which allows you to write closed source code. More importantly perhaps, it comes with support, should you have questions on the use of the language, tools, how to best implement something, and of course bug reports and enhancement requests.
-
Another number of compilers are listed in the Ada WikiBook, together with installation instructions. Getadanow.com features editions of FSF GNAT, ready-made for various operating systems on several types of hardware, or virtual machines. The site also collects resources for learning and sharing Ada.
Hello World
with Ada.Text_IO;
procedure Hello_World is
begin
Ada.Text_IO.Put_Line ("Hello World");
end Hello_World;
Alternatively, after importing the package Ada.Text_IO, you can say use Ada.Text_IO;
in order to be able to use Put_Line without explicitly declaring what package it should come from, as such:
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello_World is
begin
Put_Line ("Hello World");
end Hello_World;
If you are using the gnat
compiler, this simple program can be compiled with
gnatmake hello_world
This will generate a number of files, including a hello_world
(or hello_world.exe
on Windows) that you can execute to see the famous message. The name of the executable is computed automatically from the name of the main Ada subprogram. In Ada a main subprogram can have any name. It only has to be a parameter-less procedure, that you give as an argument to gnatmake
.
Other compilers have similar requirements, although of course the build command is different.
Version
The standard Ada programming language is defined in the Ada Reference Manual. Interim version changes and release notes are discussed in the corresponding rationale documents. Implementations typically document their compliance with the standard in the form of a user guide and/or reference manual, for example.
-
Ada 2012
-
Ada 2005
-
Ada 95
-
Ada 83
- Ada 83 Language Reference Manual
- [*Ada 83 Rationale for the Design of the
Ada® Programming Language*]10
Libraries
As for any programming language, Ada comes with extensive libraries to accomplish various tasks. Here are some pointers to some of them, although searching on github will lead some more.
-
The Ada runtime itself, distributed will all compilers, includes an extensive set of packages and annexes, ranging from data structures and containers, to input/output, string manipulation, time manipulation, files, numeric computations, multi-tasking, command line switches, random numbers,…
-
The GNAT compiler comes with its own extended runtime, with new packages in the
GNAT
hierarchy, that provide support for regular expressions, sorting, searching, unicode, CRC, time input/output, … -
gnatcoll is a library that is available from AdaCore’s libre site, and includes an extensive logging framework, extending applications with python, mmap, an extensive framework to interface with file systems, parsing email messages and mailboxes, an extensive framework to interact with databases in a type-safe manner, interface to various libraries like icon, readline, terminal colors, support for reference counted types for automatic memory management, JSON files,…
-
XML/Ada is a library to parse and validate XML documents
-
GtkAda is a full binding to the gtk+ library, that let’s you write portable user interfaces on Unix, Windows and OSX.
-
AWS is a framework to create web servers in Ada, with full support for various protocols like HTTP, Websockets,… and its own template system.