Section 1.2 - Simple Program

Here's a simple program in Ada that simply prints a message, often called the hello, world! program (for the moment, ignore the buttons below the sample program):

-- Print a simple message to demonstrate a trivial Ada program.
with Ada.Text_IO;
procedure Hello is
 Ada.Text_IO.Put_Line("Hello, world!");
end Hello;

Here's an explanation of each line:

  1. The first line illustrates a comment; Ada comments begin with ``--'' and end at the end of the line (C++ comments that begin with // work the same way).
  2. The second line illustrates a with clause, which specifies the library units (other items) that we need. This particular with clause specifies that we need Ada.Text_IO. The library unit Ada.Text_IO is a predefined library unit that provides operations to perform basic text input and output.
  3. The third line states that we're defining a new procedure named Hello. Note that in Ada there's nothing special about the name of the main program (in C and C++, it must be called main, and in Pascal, it must be specially identified as the program).
  4. The fourth line just has the keyword begin, which begins the definition of the procedure Hello.
  5. The fifth line calls Ada.Text_IO's procedure Put_Line, which prints a line to the current output (usually the screen) and then ends the current line. The basic syntax for calling a procedure is to give the library unit name, a period, the name of the procedure, and then list the parameters (if any) enclosed in parentheses (we'll see how to simplify this soon). In Ada, strings are surrounded by double quotes (the same as C and C++; Pascal uses single quotes).
  6. The last line ends the definition of the procedure.

Ada terminates each statement with a semicolon. This is like C and C++ and unlike standard Pascal (which uses semicolons as statement separators).

Unless you're using a very old browser you should see a button labelled "Compile with WebAda" below the source code. If you have a working connection to the Internet, just press that button and you'll compile the Ada code with the WebAda system. You can also make changes and see the effect of those changes. There are a few other buttons you may find useful: the "reset" button will restore the the original text, the "verbose" option will let you turn on or off verbose results, and the "configure" checkbox will let you change compilation options.

Just a quick note - if you're using an Ada 83 compiler instead of an Ada 95 compiler, please see the note about using Ada 83 before compiling this program. WebAda will normally use an Ada 95 compiler.


What is the name of the new procedure defined above?

  1. Text_IO
  2. Hello
  3. Put_Line

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to lesson 1 outline

David A. Wheeler (

The master copy of this file is at "".