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.