January 19, 1998
by Eric DeArment, Team Ada
"Why learn Ada?," you ask. I can think of at least three good reasons:
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:
So, enough on Ada's ancestry, and now on to the actual creation of the language.
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.
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.
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:
All Ada programs share a basic structure:
with Package_Name; use Package_Name; procedure Program_Name is Variable : Some_Type; begin Statement_1; Statement_2; end 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:
with Ada.Text_IO; use Ada.Text_IO; procedure Hello_World is -- no variables needed here :) begin Put ("Hello world!"); end 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:
with Ada.Text_IO; use Ada.Text_IO; procedure Get_Name is Name : String (1..80); Length : Integer; begin Put ("Enter your first name> "); Get_Line (Name, Length); New_Line; Put ("Hello "); Put (Name (1..Length)); Put (", we hope that you enjoy learning Ada!"); end 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!"
"But is there a graphical Ada development environment?," you ask. Well, yes, there is, and it comes in the form of a program by a company called Aonix, www.aonix.com, known as ObjectAda. You can find a bunch of free stuff attributed to ObjectAda at the PAL FTP site in the /languages/ada/objectada directory.
There are versions of ObjectAda for both Microsoft Windows and X-Windows. (X-Windows is the standard window system for the Unix operating system.)
Note however that ObjectAda for X-Windows is 66MB compressed and the MS-Windows version is 77MB, so if you plan on downloading it, make sure you have either a 56Kbps modem or at least a T1 network connection.
Finally, let me point you to a number of books, Internet sites, and resellers of interest to those wanting to learn more about Ada.
Ada: Problem Solving and Program Design, by Michael B. Feldman and Elliot B. Koffman. There are two versions of this book: one published in 1992, which is about Ada 83, and the other published just recently, which explains Ada 95. The book assumes no previous experience in programming, and has many great examples. I would definitely suggest using this book. The previous version actually served as my first Ada book, and I went from knowing quite little to knowing quite a lot.
Ada 95: The Craft of Object-Oriented Programming, by John English. Published in 1997, this is another great tutorial on Ada 95. Like the previous book, it doesn't assume any previous programming experience. I would also suggest this one.
To learn more about these books, go to the Ada Home Bookshop. Also, for Ada 95 books in general, read the Ada 95 book reviews.
The official Ada Web page, Ada Home (www.adahome.com) is by far one of the most helpful Ada Web sites around. It provides resources and links to such resources as compilers, books, Web-based tutorials, and FAQs.
There is also the aforementioned Public Ada Library (PAL) FTP site. It's at ftp://wuarchive.wustl.edu/languages/ada. The PAL site contains loads of great stuff, including tutorials, compilers, FAQs, and source code.
Additionally, there are two Usenet newsgroups devoted to Ada: comp.lang.ada and its French counterpart, fr.comp.lang.ada.
There's also the Team Ada mailing list for those who want to help educating the public about Ada (not for technical discussions). To subscribe, send a message with no subject to email@example.com. In the message body, type subscribe team-ada [Your name].
If you'd prefer not to die of boredom downloading stuff from FTP sites, then head to www.cdrom.com where you can purchase Walnut Creek's Ada CD-ROM, which contains the entire PAL library. The price of the CD is $39.95.
Page last modified: 1998-01-21