Ada

Introducing Ada Programming languages

Introducing Ada

by Eric DeArment, Team Ada

ejd@efn.org

“Why learn Ada?,” you ask.
I can think of at least three good reasons:

  1. It’s easy. I memorized the “Hello World” program in only minutes.

  2. It’s powerful. Ada was designed so that it could be made to do just
    about anything.

  3. It can be used as a ‘gateway’ to the more difficult C language; even
    though Ada’s syntax is very different from C’s, the two languages are
    actually similar in many ways.

Ada’s Ancestry

Back in 1957, a computer scientist at IBM Corporation named John Backus
created a new language that was intended to make it so that scientists,
engineers and mathematicians could more easily solve mathematical and
scientific problems. The language, FORTRAN, which is short for “FORmula
TRANslation,” was a complete success; forty years later, it’s still being
actively used and developed.

Across the Atlantic, in Europe, some computer scientists who had known
about FORTRAN formed a committee to create their own language, one that
they could use for the same purposes as FORTRAN. Only months later, in
1958, the new programming language, dubbed “ALGOL,” an acronym for
“ALGOrithmic Language,” was all finished, and quickly standardized.

It’s often considered “tradition” to name a computer language standard
after the year that it was standardized, so the creators of ALGOL named it
ALGOL 58. People all over Europe continued to work on ALGOL, and only two
years later, ALGOL 60 was unleashed.

ALGOL 60 is very important in the history of several languages used today,
including Ada. From ALGOL 60 we get three language families:

  1. SIMULA, created by a group of computer scientists at the University of
    Oslo in Norway.

  2. CPL, created by Ken Thompson of AT&T Bell Laboratories for the purpose
    of writing the MULTICS operating system, which was a precursor to Unix.
    CPL is the ancestor of C.

  3. Last but not least, there was Pascal, written by Niklaus Wirth
    (pronounced “Neeklowss Veert”) of the Swiss Federal Institute of Technology in Zurich,
    Switzerland for the purpose of teaching programming to college students,
    and it is from Pascal that we get Ada.

So, enough on Ada’s ancestry, and now on to the actual creation of the
language.

The Contest

In the 1960s and 1970s, the United States Department of Defense was using
more than 2,000 languages for its mission-critical programming. Most of
these were languages that were developed for one specific job. Finally,
in 1975, the DoD formed the U.S. Department of Defense High-Order
Language Working Group (HOLWG) to find a solution to what was often called
the “software crisis.”

What the HOLWG group members decided was that they needed to create a
language that they could use for just about anything, whether it be systems
programming, artificial intelligence, and, most important of all, real-time
programming and embedded systems. Real-time programs are the
programs used for controlling such things as traffic lights, guided
missiles, and bar-code scanners. Embedded systems are the
small computers that are built into most modern cars, airplanes, and
stereos.

Rather than create this new language themselves, they decided to hold a
contest. Several teams joined, each represented by a color. Coincidentally,
all of the teams created Pascal-based languages. In the end, the winner was
the green team — CII Honeywell-Bull in France. Eventually, the language was
christened “Ada,” in honor of Lady Ada Lovelace, daughter of famed poet Lord
Byron and assistant to mathematician Charles Babbage, who invented the
Analytical Machine. Lady Ada is often considered to be the world’s first
programmer.

In 1979, the DoD created its first draft documentation on Ada, and the
language was first standardized in 1983. Now named “Ada 83″, this standard was
originally controlled entirely by the DoD, and nobody outside the DoD
could create any Ada compiler without the authorization of the Defense
Department.

All that changed in 1987, however, when the DoD released Ada to the public
and the language was made an international standard by the International
Standards Organization (ISO). By 1990, over 200 validated Ada compilers had
been produced, and in 1995 a new standard, called Ada 95, was announced.
Ada 95 is object-oriented, and offers interfaces to the languages C, FORTRAN
and COBOL.

Meeting Ada

Normally, you’d probably expect a compiler for a language as powerful as
Ada 95 to cost a fortune, but you’ll be surprised when you find that one of
the most powerful and popular Ada 95 compilers, GNAT, the GNU/NYU Ada 95
Translator, is provided free of charge.

GNAT can be obtained from the Public Ada Library (PAL) FTP site,
ftp://wuarchive.wustl.edu, in the
/languages/ada/compiler/gnat
directory. This directory contains versions of GNAT for several variants of
Unix, including SunOS/Solaris, Linux, NetBSD, SGI IRIX, IBM’s AIX, DEC’s
Digital Unix, and others.

There are also versions of GNAT for WinNT, Win95, MacOS, and a version for DOS
called “EZ2Load,” which can be found in the
/compiler/ez2load directory.

The Tutorial

Now I’m going to go on to the actual tutorial part of this article. Of
course, this isn’t a complete tutorial, it’s just a brief introduction that
shows you the basic structure of an Ada program and provides a couple of
Ada programs that are ready to be compiled.

First of all, I’d like the reader to know what Ada’s actually like. Like
its ancestor Pascal and its cousin C, Ada is a structured language. In
other words, a program is organized into different sections, whereas in
unstructured languages like BASIC, you can basically put anything anywhere.

Also, Ada has its own terminology, and I will be using a few words with
whose meanings you may be unfamiliar:

  • package, a source file that stores certain commands that do such
    things as print text, perform mathematical functions, etc. Compare these
    to the header files in C.

  • variable, an area of memory in which a value such as a number, a
    character, or a word is stored.

  • statement, a command that performs a specific function.

All Ada programs share a basic structure:

     <b>with</b> Package_Name; <b>use</b> Package_Name;

     <b>procedure</b> Program_Name <b>is</b>

       Variable : Some_Type;

     <b>begin</b>

       Statement_1;
       Statement_2;

     <b>end</b> Program_Name;

The procedure is basically the program’s name.

The place where it says Variable : Some_Type is a variable
declaration. “So what does ‘Some_Type’ mean?” you ask. Well, that defines the
type of variable it is. In other words, if the variable were an integer
value, it would be changed to Variable : Integer;. If it
were a floating-point (decimal) value, it would be
Variable : Float;.

Semicolons are used to end a variable declaration or statement, allowing
you to put more than one variable declaration or statement on one line.

The statement begin begins the execution of the actual
statements of the program.

The Statement_1; and Statement_2;
lines don’t actually mean anything in Ada; in a real program they would be
replaced with commands that do something.

The statement end Program_Name; basically ends the
program. Now, this little “demo” was just meant to demonstrate the
structure of an Ada program, but now I’ll give you one that actually works.
This is the simple “Hello World” program that’s often taught to people who
are new to programming:

     <b>with</b> Ada.Text_IO; <b>use</b> Ada.Text_IO;<br /><br />     <b>procedure</b> Hello_World <b>is</b><br /><br />       -- no variables needed here :) <br /><br />     <b>begin</b><br /><br />       Put ("Hello world!");<br /><br />     <b>end</b> Hello_World;

The package “Text_IO” contains all of the functions for input/output
operations in Ada; it’s used for programs involving the display and
gathering of text. I should probably comment on why it says “Ada.”
before “Text_IO.” Because Ada can interface with so many different
languages — i.e. you can link C or COBOL code and Ada code –
and there may be libraries with thousands of packages to choose from,
it’s necessary to specify which library you are using.

The procedure name is “Hello_World.” The statements “with” and “use” evoke
the Text_IO package into the program so that its functions can be used. If
you plan on running this program, you may want to give it the name
hello_world.ada when you save it. Note: You should use the name
hello_world.adb if you’re using the GNAT compiler.

Since this program does nothing more than print a couple of words out on
the screen, there aren’t any variable declarations required, so the section
where variables are normally declared is left blank. Note the double
hyphens (–) before the text “No variables needed here :) .” Those
hyphens indicate something called a comment. A comment is a string
of text in a program that is ignored by the compiler. However, if you
intend to add the “No variables needed here :) ” string to the program and
run the program with that string in it, you must include the
double hyphens, or else the compiler will construe that as an attempt by you to use
“No variables needed here :) ” as a variable declaration, and you’ll get
an error message when you try to compile the program.
The statement Put ("Hello world!"); is the command
for actually printing the text on the screen.

Even though the use of parentheses seems to make things harder, it is
required. You can’t just write “Put “Hello world!”;”

Notice also that many of the names begin with capital letters
(“Text_IO” for example). This isn’t required, it’s just for
“touching-up.” While it isn’t required, however, it is suggested,
because just like a wood carver or a music composer, a computer
programmer wants his/her work to look presentable. :)

The next program is a little more complicated. It asks the user for his/her
first name, and then prints it out on the screen along with some other text:

     <b>with</b> Ada.Text_IO; <b>use</b> Ada.Text_IO;<br /><br />     <b>procedure</b> Get_Name <b>is</b><br /><br />       Name   : String (1..80);<br />       Length : Integer;<br /><br />     <b>begin</b><br /><br />       Put ("Enter your first name> ");<br />       Get_Line (Name, Length);<br />       New_Line;<br />       Put ("Hello ");<br />       Put (Name (1..Length));<br />       Put (", we hope that you enjoy learning Ada!");<br /><br />     <b>end</b> Get_Name;

Here’s how it works. We already know what Text_IO is,
and the statement procedure Get_Name is should also
make some sense.

The variable Name is the name entered by the user, and
the type indication String (1..80) signifies that
Name is a string of characters, i.e. a person’s name,
with up to 80 characters in it.
The second variable, Length, is an integer used to remember
the number of characters actually typed by the user of the program.

Now on to the statements. When the program is run, it will print “Enter
your first name> ” on the screen, and it will be ready to accept input from
the user. After the user enters his/her name and presses Enter, the program
will skip a line (New_Line;) and print out “Hello
[user's name], we hope that you enjoy learning Ada!”

-- Source code for an article published at the Ada Home <http://www.adahome.com/><br />--<br />--   Introducing Ada<br />--     by Eric DeArment<br />--   January 1998<br />--<br />-- See <http://www.adahome.com/articles/1998-01/ar_intro.html><br /><br /><br />with Ada.Text_IO; use Ada.Text_IO;<br /><br />procedure Get_Name is<br /><br />  Name   : String (1..80);<br />  Length : Integer;<br /><br />begin<br /><br />  Put ("Enter your first name> ");<br />  Get_Line (Name, Length);<br />  New_Line;<br />  Put ("Hello ");<br />  Put (Name (1..Length));<br />  Put (", we hope that you enjoy learning Ada!");<br /><br />end Get_Name;<br /><br /><br />

By programming on January 31, 2011 | Ada

Ada programming Compiler, Source code and Tutorial

Ada programming is is an artificial language designed to express computations that can be performed by a machine, particularly a computer.

Compiler

Download Ada programming compiler.

Source code

Ada programming Hello world sample source code.

– Hello World in Ada

with Text_IO;
procedure Hello_World is

begin
Text_IO.Put_Line(“Hello World!”);
end Hello_World;

Tutorial

Ada programming tutorial.

From aseries of talks given at the Ada Conference UK 2009 in London. Since its inception, Ada has been successful in systems where reliability is essential. Its application domains include aeronautics, air traffic control, aerospace, simulation, shipboard systems, railway systems, communications, banking and many others. It is used in environments ranging from bareboard embedded devices to large-scale distributed real-time systems, and in multi-language software interfacing with languages such as C, C++, Fortran and Java.
Video Rating: 4 / 5

From aseries of talks given at the Ada Conference UK 2009 in London. Since its inception, Ada has been successful in systems where reliability is essential. Its application domains include aeronautics, air traffic control, aerospace, simulation, shipboard systems, railway systems, communications, banking and many others. It is used in environments ranging from bareboard embedded devices to large-scale distributed real-time systems, and in multi-language software interfacing with languages such as C, C++, Fortran and Java.
Video Rating: 5 / 5

Binding Java to Ada for mixed language applications.

From aseries of talks given at the Ada Conference UK 2009 in London. Since its inception, Ada has been successful in systems where reliability is essential. Its application domains include aeronautics, air traffic control, aerospace, simulation, shipboard systems, railway systems, communications, banking and many others. It is used in environments ranging from bareboard embedded devices to large-scale distributed real-time systems, and in multi-language software interfacing with languages such as C, C++, Fortran and Java.

From aseries of talks given at the Ada Conference UK 2009 in London. Since its inception, Ada has been successful in systems where reliability is essential. Its application domains include aeronautics, air traffic control, aerospace, simulation, shipboard systems, railway systems, communications, banking and many others. It is used in environments ranging from bareboard embedded devices to large-scale distributed real-time systems, and in multi-language software interfacing with languages such as C, C++, Fortran and Java.
Video Rating: 0 / 5

www.youtube.com For more information on Charless Babbage, go here: en.wikipedia.org The contention: Ada Lovelace, an impressive mathematician, and one of the few people who fully understood Babbage’s ideas, created a program for the Analytical Engine. Had the Analytical Engine ever actually been built, her program would have been able to calculate a sequence of Bernoulli numbers. Based on this work, Lovelace is now widely credited with being the first computer programmer.[23] In 1979, a contemporary programming language was named Ada in her honour. Shortly afterward, in 1981, a satirical article by Tony Karp in the magazine Datamation described the Babbage programming language as the “language of the future”.[24] The truth is that the case for Ada Lovelace is overstated, her importance to computing trumped up. The readings were taken from page 166 of The cogwheel brain by Doron Swade. I recommend the book: www.amazon.com
Video Rating: 4 / 5

Binding Java to Ada for mixed language applications

Industrial Presentation from the Ada-Europe 2010 conference in Valencia. The presentation describes a programming technique that allows to implement polymorphic callbacks in Ada/C++ library bindings.
Video Rating: 0 / 5

Industrial Presentation from the Ada-Europe 2010 conference in Valencia. The presentation describes a programming technique that allows to implement polymorphic callbacks in Ada/C++ library bindings.

A side-by-side comparison of an object-oriented design using dynamic dispatching.
Video Rating: 0 / 5

By programming on October 16, 2010 | Ada | A comment?
Tags: , , , ,