THE ADA PROGRAMMING LANGUAGE

Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages. It has strong built-in language support for explicit concurrency, offering tasks, synchronous message passing (via guarded task entries), protected objects (a monitor-like construct with additional guards as in conditional critical regions) and nondeterminism (via select statements).

Ada was originally designed by a team led by Jean Ichbiah of CII Honeywell Bull under contract to the United States Department of Defense (DoD) from 1977 to 1983 to supersede the hundreds of programming languages then used by the DoD. Ada is strongly typed and compilers are validated for reliability in mission-critical applications, such as avionics software. Ada is an international standard; the current version (known as Ada 2005) is defined by joint ISO/ANSI standard,[2] combined with major Amendment ISO/IEC 8652:1995/Amd 1:2007.[3]

Ada was named after Ada Lovelace (1815–1852), who is sometimes credited as being the first computer programmer.[4]
Contents
[hide]

* 1 Features
* 2 History
* 3 Standardization
* 4 Language constructs
o 4.1 “Hello, world!” in Ada
o 4.2 Data types
o 4.3 Control structures
o 4.4 Packages, procedures and functions
o 4.5 Concurrency
o 4.6 Pragmas
* 5 See also
* 6 Notes
* 7 References
o 7.1 International Standards
o 7.2 Rationale
o 7.3 Books
o 7.4 Archives
* 8 External links

[edit] Features

Ada was originally targeted at embedded and real-time systems. The Ada 95 revision, designed by S. Tucker Taft of Intermetrics between 1992 and 1995, improved support for systems, numerical, financial, and object-oriented programming (OOP).

Notable features of Ada include: strong typing, modularity mechanisms (packages), run-time checking, parallel processing (tasks, synchronous Message passing, protected objects and nondeterministic select statements), exception handling, and generics. Ada 95 added support for object-oriented programming, including dynamic dispatch.

The syntax of Ada is simple, consistent and readable. It minimizes choices of ways to perform basic operations, and prefers English keywords (e.g. “or else”) to symbols (e.g. “||”). Ada uses the basic mathematical symbols (i.e.: “+”, “-“, “*” and “/”) for basic mathematical operations but avoids using other symbols. Code blocks are delimited by words such as “declare”, “begin” and “end”, whereas the “end” (in most cases) is followed by the identifier of the block it closes (e.g. if.. end if, loop … end loop). In the case of conditional blocks this avoids a dangling else that could pair with the wrong nested if-expression in other languages.

Ada is designed for development of very large software systems. Ada packages can be compiled separately, and furthermore, Ada package specifications (the package interface) can be compiled separately without the implementation to check for consistency – this makes it possible to detect problems early during the design phase, before implementation starts.

A large number of compile-time checks are supported to help avoid bugs that would not be detectable until run-time in some other languages or would require explicit checks to be added to the source code. For example, the syntax requires explicitly named closing of blocks to prevent errors due to mismatched end tokens. The adherence to strong typing allows detection of many common software errors (wrong parameters, range violations, invalid references, mismatched types, etc.) either during compile-time, or otherwise during run-time. As concurrency is part of the language specification, the compiler can in some cases detect potential deadlocks. Compilers also commonly check for misspelled identifiers, visibility of packages, redundant declarations, etc. and can provide warnings and useful suggestions on how to fix the error.

Ada also supports run-time checks to protect against access to unallocated memory, buffer overflow errors, range violations, off-by-one errors, array access errors, and other detectable bugs. These checks can be disabled in the interest of runtime efficiency, but can often be compiled efficiently. It also includes facilities to help program verification. For these reasons, Ada is widely used in critical systems, where any anomaly might lead to very serious consequences, e.g., accidental death, injury or severe financial loss. Examples of systems where Ada is used include avionics, railways, banking, military and space technology.[5][6]

Ada’s dynamic memory management is high-level and type-safe. Ada does not have generic (and vague) “pointers”; nor does it implicitly declare any pointer type. Instead, all dynamic memory allocation and deallocation must take place through explicitly declared access types. Each access type has an associated storage pool that handles the low-level details of memory management; the programmer can either use the default storage pool or define new ones (this is particularly relevant for Non-Uniform Memory Access). It is even possible to declare several different access types that all designate the same type but use different storage pools. Also, the language provides for accessibility checks, both at compile time and at run time, that ensures that an access value cannot outlive the type of the object it points to.

Though the semantics of the language allow automatic garbage collection of inaccessible objects, most implementations do not support it by default, as it would cause unpredictable behaviour in real-time systems. Ada does support a limited form of region-based storage management; also, creative use of storage pools can provide for a limited form of automatic garbage collection, since destroying a storage pool also destroys all the objects in the pool.

Ada was designed to use the English language standard for comments: the em-dash, as a double-dash (“–“) to denote comment text. Comments stop at end of line, so there is no danger of unclosed comments accidentally voiding whole sections of source code. Comments can be nested: prefixing each line (or column) with “–” will skip all that code, while being clearly denoted as a column of repeated “–” down the page. There is no limit to the nesting of comments, thereby allowing prior code, with commented-out sections, to be commented-out as even larger sections. All Unicode characters are allowed in comments, such as for symbolic formulas (E[0]=m×c²). To the compiler, the double-dash is treated as end-of-line, allowing continued parsing of the language as a context-free grammar.

The semicolon (“;”) is a statement terminator, and the null or no-operation statement is null;. A single ; without a statement to terminate is not allowed. This allows for a better quality of error messages.

Code for complex systems is typically maintained for many years, by programmers other than the original author. It can be argued that these language design principles apply to most software projects, and most phases of software development, but when applied to complex, safety critical projects, benefits in correctness, reliability, and maintainability take precedence over (arguable) costs in initial development.

Unlike most ISO standards, the Ada language definition (known as the Ada Reference Manual or ARM, or sometimes the Language Reference Manual or LRM) is free content. Thus, it is a common reference for Ada programmers and not just programmers implementing Ada compilers. Apart from the reference manual, there is also an extensive rationale document which explains the language design and the use of various language constructs. This document is also widely used by programmers. When the language was revised, a new rationale document was written.

One notable free software tool that is used by many Ada programmers to aid them in writing Ada source code is GPS, the GNAT Programming Studio.
[edit] History

In the 1970s, the US Department of Defense (DoD) was concerned by the number of different programming languages being used for its embedded computer system projects, many of which were obsolete or hardware-dependent, and none of which supported safe modular programming. In 1975, the High Order Language Working Group (HOLWG) was formed with the intent to reduce this number by finding or creating a programming language generally suitable for the department’s requirements. The result was Ada. The total number of high-level programming languages in use for such projects fell from over 450 in 1983 to 37 by 1996.
Wikisource has original text related to this article:
Steelman language requirements

The working group created a series of language requirements documents—the Strawman, Woodenman, Tinman, Ironman and Steelman documents. Many existing languages were formally reviewed, but the team concluded in 1977 that no existing language met the specifications.

Requests for proposals for a new programming language were issued and four contractors were hired to develop their proposals under the names of Red (Intermetrics led by Benjamin Brosgol), Green (CII Honeywell Bull, led by Jean Ichbiah), Blue (SofTech, led by John Goodenough), and Yellow (SRI International, led by Jay Spitzen). In April 1978, after public scrutiny, the Red and Green proposals passed to the next phase. In May 1979, the Green proposal, designed by Jean Ichbiah at CII Honeywell Bull, was chosen and given the name Ada—after Augusta Ada, Countess of Lovelace. This proposal was influenced by the programming language LIS that Ichbiah and his group had developed in the 1970s. The preliminary Ada reference manual was published in ACM SIGPLAN Notices in June 1979. The Military Standard reference manual was approved on December 10, 1980 (Ada Lovelace’s birthday), and given the number MIL-STD-1815 in honor of Ada Lovelace’s birth year. In 1981, C. A. R. Hoare took advantage of his Turing Award speech to criticize Ada for being overly complex and hence unreliable,[7] but subsequently seemed to recant in the foreword he wrote for an Ada textbook.[8]

Ada attracted much attention from the programming community as a whole during its early days. Its backers and others predicted that it might become a dominant language for general purpose programming and not just defense-related work. Ichbiah publicly stated that within ten years, only two programming languages would remain, Ada and Lisp.[9] Early Ada compilers struggled to implement the large, complex language, and both compile-time and run-time performance tended to be slow and tools primitive. Compiler vendors expended most of their efforts in passing the massive, language-conformance-testing, government-required “ACVC” validation suite that was required in another novel feature of the Ada language effort.[9]

The first validated Ada implementation was the NYU Ada/ED translator,[10] certified on April 11, 1983. NYU Ada/ED was implemented in the high-level set language SETL.[11]
Augusta Ada King, Countess of Lovelace.

In 1987, the US Department of Defense began to require the use of Ada (the Ada mandate) for every software project where new code was more than 30% of result, though exceptions to this rule were often granted.

By the late 1980s and early 1990s, Ada compilers had improved in performance, but there were still barriers to full exploitation of Ada’s abilities, including a tasking model that was different from what most real-time programmers were used to.[9]

The Department of Defense Ada mandate was effectively removed in 1997, as the DoD began to embrace COTS (commercial off-the-shelf) technology. Similar requirements existed in other NATO countries.

Because of Ada’s safety-critical support features, it is now used not only for military applications, but also in commercial projects where a software bug can have severe consequences, e.g. aviation and air traffic control, commercial rockets (e.g. Ariane 4 and 5), satellites and other space systems, railway transport and banking.[6] For example, the fly-by-wire system software in the Boeing 777 was written in Ada. The Canadian Automated Air Traffic System was written in 1 million lines of Ada (SLOC count). It featured advanced distributed processing, a distributed Ada database, and object-oriented design. Ada is also used in other air traffic systems, e.g. the UK’s next-generation Interim Future Area Control Tools Support (iFACTS) air traffic control system is designed and implemented using SPARK Ada [12] It is also used in the French TVM in-cab signalling system on the TGV high speed rail system, and the metro suburban trains in Paris, London, Hong Kong and New York City.[6][13]
[edit] Standardization

The language became an ANSI standard in 1983 (ANSI/MIL-STD 1815A), and without any further changes became an ISO standard in 1987 (ISO-8652:1987). This version of the language is commonly known as Ada 83, from the date of its adoption by ANSI, but is sometimes referred to also as Ada 87, from the date of its adoption by ISO.

Ada 95, the joint ISO/ANSI standard (ISO-8652:1995) was published in February 1995, making Ada 95 the first ISO standard object-oriented programming language. To help with the standard revision and future acceptance, the US Air Force funded the development of the GNAT Compiler. Presently, the GNAT Compiler is part of the GNU Compiler Collection.

Work has continued on improving and updating the technical content of the Ada programming language. A Technical Corrigendum to Ada 95 was published in October 2001, and a major Amendment, ISO/IEC 8652:1995/Amd 1:2007, the current version of the standard, was published on March 9, 2007. Work on the next significant Ada Amendment is planned to be completed by 2012.(ISO/IEC 8652:201z Ed. 3)

Other related standards include ISO 8651-3:1988 Information processing systems—Computer graphics—Graphical Kernel System (GKS) language bindings—Part 3: Ada.
[edit] Language constructs

Ada is an ALGOL-like programming language featuring control structures with reserved words such as if, then, else, while, for, and so on. However, Ada also has many data structuring facilities and other abstractions which were not included in the original ALGOL 60, such as type definitions, records, pointers, enumerations. Such constructs were in part inherited or inspired from Pascal.
[edit] “Hello, world!” in Ada

A common example of a language’s syntax is the Hello world program: (A more in-depth example can be found here) (hello.adb)

with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
Put_Line(“Hello, world!”);
end Hello;

This program can be compiled e.g. by using the freely available open source compiler GNAT, by executing

gnatmake hello.adb

[edit] Data types

Ada’s type system is not based on a set of predefined primitive types but allows users to declare their own types. This declaration in turn is not based on the internal representation of the type but on describing the goal which should be achieved. This allows the compiler to determine a suitable memory size for the type, and to check for violations of the type definition at compile time and run time (i.e. range violations, buffer overruns, type consistency, etc.). Ada supports numerical types defined by a range, modulo types, aggregate types (records and arrays), and enumeration types. Access types define a reference to an instance of a specified type; untyped pointers are not permitted. Special types provided by the language are task types and protected types.

For example a date might be represented as:

type Day_type is range 1 .. 31;
type Month_type is range 1 .. 12;
type Year_type is range 1800 .. 2100;
type Hours is mod 24;
type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);

type Date is
record
Day : Day_type;
Month : Month_type;
Year : Year_type;
end record;

Types can have modifiers such as limited, abstract, private etc. Private types can only be accessed and limited types can only be modified or copied within the scope of the package that defines them.[14] Ada 95 adds additional features for object-oriented extension of types.
[edit] Control structures

Ada is a structured programming language, meaning that the flow of control is structured into standard statements. All standard constructs and deep level early exit are supported so the use of the also supported ‘go to’ commands is seldom needed.

while a /= b loop
Ada.Text_IO.Put_Line (“Waiting”);
end loop;

if a > b then
Ada.Text_IO.Put_Line (“Condition met”);
else
Ada.Text_IO.Put_Line (“Condition not met”);
end if;

for i in 1 .. 10 loop
Ada.Text_IO.Put (“Iteration: “);
Ada.Text_IO.Put (i);
Ada.Text_IO.Put_Line;
end loop;

loop
a := a + 1;
exit when a = 10;
end loop;

case i is
when 0 => Ada.Text_IO.Put(“zero”);
when 1 => Ada.Text_IO.Put(“one”);
when 2 => Ada.Text_IO.Put(“two”);
— case statements have to cover all possible cases:
when others => Ada.Text_IO.Put(“none of the above”);
end case;

[edit] Packages, procedures and functions

Ada programs consist of packages, procedures and functions.

Example: Package specification (example.ads)

Package Example is
type Number is range 1 .. 11;
procedure Print_and_Increment (j: in out Number);
end Example;

Package implementation (example.adb)

with Ada.Text_IO;
Package body Example is

i : Number := Number’First;

procedure Print_and_Increment (j: in out Number) is

function Next (k: in Number) return Number is
begin
return k + 1;
end Next;

begin
Ada.Text_IO.Put_Line (‘The total is: ‘ & Number’Image(j));
j := Next (j);
end Print_and_Increment;

begin
while i — landings have priority
accept Request_Takeoff (ID : in Airplane_ID; Takeoff : out Runway_Access) do
My_Runway.Assign_Aircraft (ID); — reserve runway
Takeoff := My_Runway; — tell airplane which runway
end Request_Takeoff; — end of the synchronised part
or
accept Request_Approach (ID : in Airplane_ID; Approach : out Runway_Access) do
My_Runway.Assign_Aircraft (ID);
Approach := My_Runway;
end Request_Approach;
or — terminate if nobody left who could call
terminate;
end select;
end loop;
end;

task body Airplane is
Rwy : Runway_Access;
begin
Controller1.Request_Takeoff (ID, Rwy); — wait to be cleared for takeoff
Put_Line (Airplane_ID’Image (ID) & ” taking off…”); delay 2.0;
Rwy.Cleared_Runway (ID);
delay 5.0; — fly around a bit…
loop
select — try to request a runway
Controller1.Request_Approach (ID, Rwy); — this is a blocking call
exit; — if call returned we’re clear for landing – proceed…

or delay 3.0; — timeout – if no answer in 3 seconds, do something else
Put_Line (Airplane_ID’Image (ID) & ” in holding pattern”);
end select;
end loop;
delay 4.0; — do landing approach…
Put_Line (Airplane_ID’Image (ID) & ” touched down!”);
Rwy.Cleared_Runway(ID); — notify runway that we’re done here.
end;

New_Airplane: Airplane_Access;
begin
for I in Airplane_ID’Range loop — create a few airplane tasks
New_Airplane := new Airplane(I); delay 3.0;
end loop;
end Traffic;

[edit] Pragmas

A pragma is a compiler directive that convey information to the compiler to allow specific manipulation of compiled output.[15] Certain pragmas are built in to the language[16] while other are implementation-specific.

Examples of common usage of compiler pragmas would be to disable certain features, such as run-time type checking or array subscript boundary checking, or to instruct the compiler to insert object code in lieu of a function call (as C/C++ does with inline functions).
[edit] See also

* APSE – a specification for a programming environment to support software development in Ada
* List of programming languages
* SPARK (programming language) – a programming language consisting of a highly restricted subset of the Ada, annotated with meta information describing desired component behavior and individual runtime requirements
* VHDL – a hardware description language originally developed at the behest of the U.S Department of Defense that borrows heavily from Ada in both concepts and syntax
* PL/SQL
* JOVIAL
* Ravenscar profile
* Comparison of programming languages

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s