Ada (programming language)#"Hello, world!" in Ada

{{short description|High-level programming language first released in 1980}}

{{infobox programming language

| name = Ada

| logo = Ada horizon green logo with slogan.svg

| logo_size = 200px

| logo alt = Green logo on horizon with Ada letters and slogan

| paradigm = Multi-paradigm: structured, imperative, object-oriented, aspect-oriented,{{cite web|url=http://www.adacore.com/uploads/technical-papers/Ada2012_Rational_Introducion.pdf|title=Ada2012 Rationale|website=adacore.com|access-date=5 May 2018|url-status=live|archive-url=https://web.archive.org/web/20160418132340/http://www.adacore.com/uploads/technical-papers/Ada2012_Rational_Introducion.pdf|archive-date=18 April 2016}} concurrent, array, distributed, generic, procedural, meta

| family = Pascal

| designers = * MIL-STD-1815, Ada 83: Jean Ichbiah

  • Ada 95: Tucker Taft
  • Ada 2005: Tucker Taft
  • Ada 2012: Tucker Taft

| developer =

| typing = static, strong, safe, nominal

| implementations = AdaCore GNAT,{{Cite web|url=https://www.adacore.com/download|title=Commercial software solutions for Ada, C and C++|website=AdaCore|access-date=Apr 4, 2023}}
Green Hills Software Optimising Ada 95 compiler,
PTC ApexAda and ObjectAda,{{cite news|url=http://www.ptc.com/developer-tools/objectada |title=PTC ObjectAda |publisher=PTC.com |access-date=2014-01-27}}
MapuSoft Ada-C/C++ changer,{{cite web|url=https://www.mapusoft.com/ada-to-c-changer/|title=MapuSoft Ada-C/C++ changer|date=16 April 2019}} formerly known as "AdaMagic with C Intermediate",{{Cite web|url=http://ada-auth.org/cpl/details/151.html|title=Ada 95 Certified Processors List – Details|website=ada-auth.org|access-date=Apr 4, 2023}}
DDC-I Score

| dialects = SPARK, Ravenscar profile

| influenced = C++, Chapel,{{cite web|title=Chapel spec (Acknowledgements)|url=http://chapel.cray.com/spec/spec-0.98.pdf |archive-url=https://ghostarchive.org/archive/20221009/http://chapel.cray.com/spec/spec-0.98.pdf |archive-date=2022-10-09 |url-status=live|date=2015-10-01|access-date=2016-01-14|publisher=Cray Inc}} Drago,{{cite web|url=http://www.iuma.ulpgc.es/users/gsd/Drago/|title=Drago|access-date=2018-08-06|archive-date=2020-09-14|archive-url=https://web.archive.org/web/20200914212150/http://www.iuma.ulpgc.es/users/gsd/Drago/}} D, Eiffel, Griffin,{{Cite web|url=https://cs.nyu.edu/~goldberg/griffin.html|title=The Griffin Project|website=cs.nyu.edu|access-date=Apr 4, 2023}} Java, Nim, ParaSail, PL/SQL, PL/pgSQL, Python, Ruby, Seed7, SPARforte,{{Cite web|url=https://www.sparforte.com/|title=SparForte Programming Language|website=www.sparforte.com|access-date=Apr 4, 2023}} Sparkel, SQL/PSM, VHDL

| license =

| released = {{Start date and age|1980|02}}

| latest release version = Ada 2022

| latest release date = May 2023

| latest preview version =

| latest preview date =

| influenced by = ALGOL 68, Pascal, Simula 67,Ada Rationale, 1986, pp. 23, 70, 110–114, 137, 165, 236 C++ (Ada 95), Smalltalk (Ada 95), Modula-2 (Ada 95) Java (Ada 2005), Eiffel (Ada 2012)

| operating system = Multi- or cross-platform

| file ext = .adb, .ads

| website = {{URL|https://www.adaic.org/|adaic.org}}

| wikibooks = Ada Programming

}}

Ada is a structured, statically typed, imperative, and object-oriented high-level programming language, inspired by Pascal and other languages. It has built-in language support for design by contract (DbC), extremely strong typing, explicit concurrency, tasks, synchronous message passing, protected objects, and non-determinism. Ada improves code safety and maintainability by using the compiler to find errors in favor of runtime errors. Ada is an international technical standard, jointly defined by the International Organization for Standardization (ISO), and the International Electrotechnical Commission (IEC). {{As of|May 2023}}, the standard, ISO/IEC 8652:2023, is called Ada 2022 informally.{{cite journal |last1=Pinho |first1=Luis Miguel |title=From the Editor's Desk |journal=Ada Letters |volume=XLIII |number=1 |publisher=Association for Computing Machinery |date=June 2023 |page=3 |doi=10.1145/3631483 |doi-broken-date=1 November 2024 |url=https://dl.acm.org/action/showFmPdf?doi=10.1145%2F3631483}}

Ada was originally designed by a team led by French computer scientist Jean Ichbiah of Honeywell under contract to the United States Department of Defense (DoD) from 1977 to 1983 to supersede over 450 programming languages then used by the DoD.{{cite web|title=The Ada Programming Language|url=http://groups.engin.umd.umich.edu/CIS/course.des/cis400/ada/ada.html|website=University of Mich|access-date=27 May 2016|archive-url=https://web.archive.org/web/20160522063844/http://groups.engin.umd.umich.edu/CIS/course.des/cis400/ada/ada.html|archive-date=2016-05-22}} Ada was named after Ada Lovelace (1815–1852), who has been credited as the first computer programmer.{{cite journal|doi=10.1109/MAHC.2003.1253887|title=Lovelace & Babbage and the creation of the 1843 'notes'|journal=IEEE Annals of the History of Computing|volume=25|issue=4|pages=16–26|year=2003|last1=Fuegi|first1=J|last2=Francis|first2=J|s2cid=40077111}}

Features

Ada was originally designed for 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).

Features of Ada include: strong typing, modular programming 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 minimizes choices of ways to perform basic operations, and prefers English keywords (such as {{code|or else}} and {{code|and then}}) to symbols (such as {{code|{{!}}{{!}}}} and {{code|&&}}). Ada uses the basic arithmetical operators {{code|+}}, {{code|-}}, {{code|*}}, and {{code|/}}, but avoids using other symbols. Code blocks are delimited by words such as 'declare', 'begin', and 'end', where the 'end' (in most cases) is followed by the keyword of the block that it closes (e.g., {{code|if}} ... {{code|end if}}, {{code|loop}} ... {{code|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 such as C or Java.

Ada is designed for developing very large software systems. Ada packages can be compiled separately. Ada package specifications (the package interface) can also 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 detecting 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.{{cite book |url=https://www.adaic.org/resources/add_content/docs/95style/html/sec_6/|chapter=Concurrency |title=Ada 95 Quality and Style Guide|publisher=Ada Information Clearinghouse |access-date=November 5, 2021}} 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 sometimes 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, air traffic control, railways, banking, military and space technology.{{cite web|title=Ada helps churn out less-buggy code|url=http://gcn.com/Articles/1999/06/30/Ada-helps-churn-out-lessbuggy-code.aspx|publisher=Government Computer News|access-date=2010-09-14|last1=Taft|first1=S. Tucker|last2=Olsen|first2=Florence|pages=2–3|date=1999-06-30|archive-date=2015-08-31|archive-url=https://web.archive.org/web/20150831211902/http://gcn.com/Articles/1999/06/30/Ada-helps-churn-out-lessbuggy-code.aspx}}{{cite web |last=Feldman |first=Michael |title=Who's Using Ada? Real-World Projects Powered by the Ada Programming Language November 2014 |url=https://www2.seas.gwu.edu/~mfeldman/ada-project-summary.html#Banking_and_Financial_Systems |publisher=SIGAda Education Working Group}}

{{anchor|Access type}}Ada's dynamic memory management is high-level and type-safe. Ada has no generic or untyped pointers; nor does it implicitly declare any pointer type. Instead, all dynamic memory allocation and deallocation must occur via 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.[https://youtube.com/watch?v=RyY01fRyGhM&t=419 no safe dynamic memory management in ADA], in: Writing Linux Kernel Modules in Safe Rust – Geoffrey Thomas & Alex Gaynor, The Linux Foundation, 2019-10-02

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 supports a limited form of region-based memory management, and in Ada, destroying a storage pool also destroys all the objects in the pool.

A double-dash ({{code|--}}), resembling an em dash, denotes comment text. Comments stop at end of line; there is intentionally no way to make a comment span multiple lines, to prevent unclosed comments from accidentally voiding whole sections of source code. Disabling a whole block of code therefore requires the prefixing of each line (or column) individually with {{code|--}}. While this clearly denotes disabled code by creating a column of repeated '--' down the page, it also renders the experimental dis/re-enablement of large blocks a more drawn-out process in editors without block commenting support.

The semicolon ({{code|;}}) is a statement terminator, and the null or no-operation statement is {{code|null;}}. A single {{code|;}} without a statement to terminate is not allowed.

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, not only 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 the GNAT Programming Studio, and GNAT which is part of the GNU Compiler Collection.

Alire is a package and toolchain management tool for Ada.{{Cite web | url = https://alire.ada.dev | title= Alire - Homepage | publisher = Adacore | access-date = 2024-12-09}}

History

In the 1970s the US Department of Defense (DoD) became 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, a working group, 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 and the UK Ministry of Defence's requirements. After many iterations beginning with an original straw-man proposal{{Cite web|url=http://iment.com/maida/computer/requirements/strawman.htm|title=DoD – Strawman Requirements – April 1975|website=iment.com|access-date=Apr 4, 2023}} the eventual programming language was named Ada. The total number of high-level programming languages in use for such projects fell from over 450 in 1983 to 37 by 1996.

HOLWG crafted the Steelman language requirements , a series of documents stating the requirements they felt a programming language should satisfy. Many existing languages were formally reviewed, but the team concluded in 1977 that no existing language met the specifications. The requirements were created by the United States Department of Defense in The Department of Defense Common High Order Language program in 1978. The predecessors of this document were called, in order, "Strawman", "Woodenman", "Tinman" and "Ironman".Department of Defense (June 1978), [https://web.archive.org/web/20200914235620/https://dwheeler.com/steelman/steelman.htm Requirements for High Order Computer Programming Languages: "Steelman"] The requirements focused on the needs of embedded computer applications, and emphasised reliability, maintainability, and efficiency. Notably, they included exception handling facilities, run-time checking, and parallel computing.

It was concluded that no existing language met these criteria to a sufficient extent,SoftTech Inc. (1976), "Evaluation of ALGOL 68, Jovial J3B, Pascal, Simula 67, and TACPOL Versus TINMAN - Requirements for a Common High Order Programming Language." - See also: ALGOL 68, JOVIAL J3B, Pascal, Simula 67, and TACPOL (Defense Technical Information Center - DTIC ADA037637, Report Number 1021-14) so a contest was called to create a language that would be closer to fulfilling them. The design that won this contest became the Ada programming language. The resulting language followed the Steelman requirements closely, though not exactly.

File:Ada Lovelace portrait.jpg

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 (Honeywell, led by Jean Ichbiah), Blue (SofTech, led by John Goodenough){{cite web|url=http://www.sei.cmu.edu/about/people/jbg.cfm |title=John Goodenough | SEI Staff Profile |publisher=Sei.cmu.edu |access-date=2014-01-27}} 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 Honeywell, was chosen and given the name Ada—after Augusta Ada King, Countess of Lovelace, usually known as Ada Lovelace. This proposal was influenced by the 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, Tony Hoare took advantage of his Turing Award speech to criticize Ada for being overly complex and hence unreliable,{{cite journal |last=C.A.R. |first=Hoare |author-link=Tony Hoare |date=1981 |title=The Emperor's Old Clothes |url=http://zoo.cs.yale.edu/classes/cs422/2011/bib/hoare81emperor.pdf |url-status=live |journal=Communications of the ACM |publisher=Association for Computing Machinery |volume=24 |issue=2 |pages=75–83 |doi=10.1145/358549.358561 |s2cid=97895 |archive-url=https://web.archive.org/web/20160304012013/http://zoo.cs.yale.edu/classes/cs422/2011/bib/hoare81emperor.pdf |archive-date=2016-03-04 |doi-access=free}} but subsequently seemed to recant in the foreword he wrote for an Ada textbook.{{cite book |last1=Watt |first1=D.A. |last2=Wichmann |first2=B.A. |last3=Findlay |first3=W. |title=Ada: Language and Methodology |publisher=Prentice-Hall |date=1987}}

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 only defense-related work. Ichbiah publicly stated that within ten years, only two programming languages would remain: Ada and Lisp.{{cite journal |last=Rosen |first=J-P. |title=The Ada Paradox(es) |journal=Ada Letters |publisher=ACM SIGAda |volume=24 |issue=2 |date=August 2009 |pages=28–35|doi=10.1145/1620593.1620597 |s2cid=608405}} 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 Ada Compiler Validation Capability (ACVC) validation suite that was required in another novel feature of the Ada language effort.

The first validated Ada implementation was the NYU Ada/Ed translator,{{cite web |url=http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA136759 |title=Ada Compiler Validation Summary Report: NYU Ada/ED, Version 19.7 V-001 |author=SofTech Inc. |place=Waltham, MA |date=1983-04-11 |access-date=2010-12-16 |archive-url=https://web.archive.org/web/20120312080046/http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA136759 |archive-date=2012-03-12 }} certified on April 11, 1983. NYU Ada/Ed is implemented in the high-level set language SETL.{{cite book |last1=Dewar |first1=Robert B. K. |last2=Fisher |first2=Gerald A. Jr. |last3=Schonberg |first3=Edmond |last4=Froelich |first4=Robert |last5=Bryant |first5=Stephen |last6=Goss |first6=Clinton F. |last7=Burke |first7=Michael |title=Proceeding of the ACM-SIGPLAN symposium on Ada programming language – SIGPLAN '80 |chapter=The NYU Ada translator and interpreter |volume=15 |issue=11 |pages=194–201 |date=November 1980 |isbn=0-89791-030-3 |doi=10.1145/948632.948659|s2cid=10586359}} Several commercial companies began offering Ada compilers and associated development tools, including Alsys, TeleSoft, DDC-I, Advanced Computer Techniques, Tartan Laboratories, Irvine Compiler, TLD Systems, and Verdix.{{cite news |title=Ada Validated Compilers List |publisher=Ada Information Clearinghouse |date=July 1, 1992 |pages=1–36}} Computer manufacturers who had a significant business in the defense, aerospace, or related industries, also offered Ada compilers and tools on their platforms; these included Concurrent Computer Corporation, Cray Research, Inc., Digital Equipment Corporation, Harris Computer Systems, and Siemens Nixdorf Informationssysteme AG.

In 1991, the US Department of Defense began to require the use of Ada (the Ada mandate) for all software,{{cite web|url=http://archive.adaic.com/pol-hist/policy/mandate.txt |title=The Congressional Ada Mandate |author=Ada Information Clearinghouse |date=1994 |access-date=2015-06-07 |archive-url=https://web.archive.org/web/20160304073005/http://archive.adaic.com/pol-hist/policy/mandate.txt |archive-date=2016-03-04}} though exceptions to this rule were often granted. The Department of Defense Ada mandate was effectively removed in 1997, as the DoD began to embrace commercial off-the-shelf (COTS) technology.{{cite conference |contribution=The rise, fall and persistence of Ada |first=Ricky E. |last=Sward |date=November 2010 |title=SIGAda '10: Proceedings of the ACM SIGAda annual international conference on SIGAda |pages=71–74 |url=http://dl.acm.org/citation.cfm?id=1879063.1879081&coll=DL&dl=GUIDE&CFID=551420221&CFTOKEN=60383966 | doi=10.1145/1879063.1879081|isbn=978-1-4503-0027-8}} Similar requirements existed in other NATO countries: Ada was required for NATO systems involving command and control and other functions, and Ada was the mandated or preferred language for defense-related applications in countries such as Sweden, Germany, and Canada.{{cite book |url=http://apps.dtic.mil/dtic/tr/fulltext/u2/a217657.pdf |archive-url=https://web.archive.org/web/20191215065214/http://www.dtic.mil/dtic/tr/fulltext/u2/a217657.pdf |url-status=live |archive-date=December 15, 2019 |first=Nicholas J. |last=Babiak |title=Ada, the New DoD Weapon System Computer Language – Panacea or Calamity |publisher=Air University (United States Air Force) |date=1989 |pages=39–40}}

By the late 1980s and early 1990s, Ada compilers had improved in performance, but there were still barriers to fully exploiting Ada's abilities, including a tasking model that was different from what most real-time programmers were used to.

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., avionics and air traffic control, commercial rockets such as the Ariane 4 and 5, satellites and other space systems, railway transport and banking.

For example, the Primary Flight Control System, the fly-by-wire system software in the Boeing 777, was written in Ada, as were the fly-by-wire systems for the aerodynamically unstable Eurofighter Typhoon,{{cite web |date=16 June 1999 |title=Agile thinking |url=https://www.flightglobal.com/agile-thinking/26933.article |url-status=live |archive-url=https://web.archive.org/web/20210415054346/https://www.flightglobal.com/agile-thinking/26933.article |archive-date=15 April 2021 |access-date=13 Feb 2024 |website=FlightGlobal}} Saab Gripen,{{Cite web |last=Frisberg |first=Bo |title=Usage of Ada in the Gripen Flight Control System |url=https://www.sigada.org/conf/sa98/papers/frisberg.pdf |url-status=live |archive-url=https://web.archive.org/web/20240115002036/https://www.sigada.org/conf/sa98/papers/frisberg.pdf |archive-date=15 Jan 2024 |access-date=13 Feb 2024 |website=The Special Interest Group on Ada}} Lockheed Martin F-22 Raptor and the DFCS replacement flight control system for the Grumman F-14 Tomcat. 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 ({{proper name|iFACTS}}) air traffic control system is designed and implemented using SPARK Ada.{{cite web|last=AdaCore|title=GNAT Pro Chosen for UK's Next Generation ATC System|url=http://www.adacore.com/2007/06/19/adacore-gnat-pro-chosen-for-uk-next-generation/|access-date=2011-03-01|archive-url=https://web.archive.org/web/20101224163518/http://www.adacore.com/2007/06/19/adacore-gnat-pro-chosen-for-uk-next-generation/|archive-date=2010-12-24}}

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.{{cite web|last=AdaCore|title=Look Who's Using Ada|url=http://www.adacore.com/home/ada_answers/lookwho/|access-date=2011-03-01|archive-url=https://web.archive.org/web/20101224102110/http://www.adacore.com/home/ada_answers/lookwho|archive-date=2010-12-24}}

The Ada 95 revision of the language went beyond the Steelman requirements, targeting general-purpose systems in addition to embedded ones, and adding features supporting object-oriented programming.David A. Wheeler (1997), [https://web.archive.org/web/20200914235617/https://dwheeler.com/steelman/steeltab.htm "Ada, C, C++, and Java vs. The Steelman"]. Originally published in Ada Letters July/August 1997

Standardization

class="wikitable floatright" style="margin-left: 1.5em;"

|+Timeline of Ada language

Year

! Informal name

! Official Standard

1980

| Ada

| ANSI MIL-STD 1815

1983

| Ada 83/87

| ANSI MIL-STD 1815A
ISO/IEC 8652:1987

1995

| Ada 95

| ISO/IEC 8652:1995

2007

| Ada 2005

| ISO/IEC 8652:1995/Amd 1:2007

2012

| Ada 2012

| ISO/IEC 8652:2012

2023

| Ada 2022

| ISO/IEC 8652:2023

Preliminary Ada can be found in ACM Sigplan Notices Vol 14, No 6, June 1979{{cite web|url=https://dl.acm.org/doi/pdf/10.1145/956650.956651 |title=ACM Sigplan Notices |volume=14 |number= 6 |date=June 1979|pages=1–145 |doi=10.1145/956650.956651 |last1=Ichbiah |first1=J. D.}}

Ada was first published in 1980 as an ANSI standard ANSI/MIL-STD 1815. As this very first version held many errors and inconsistencies, {{Efn|see Summary of Ada Language Changes[https://dl.acm.org/doi/pdf/10.1145/989791.989792 Summary of Ada Language Changes]}} the revised edition was published in 1983 as ANSI/MIL-STD 1815A. Without any further changes, it became an ISO standard in 1987.{{Cite web |last= |date=2013-02-21 |title=ISO 8652:1987 |url=https://www.iso.org/standard/16028.html |access-date=2024-01-19 |website=ISO |language=en}} 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.{{Cite web |title=Ada 83 LRM, Front Page |url=http://archive.adaic.com/standards/83lrm/html/Welcome.html |access-date=2024-01-19 |website=archive.adaic.com}} There is also a French translation; DIN translated it into German as DIN 66268 in 1988.

Ada 95, the joint ISO/IEC/ANSI standard ISO/IEC 8652:1995{{Cite web |last= |title=ISO/IEC 8652:1995 |url=https://www.iso.org/standard/22983.html |access-date=2024-01-19 |website=ISO |language=en}}{{Cite web |title=Ada 95 Language Reference Manual (original) – Ada Resource Association |url=https://www.adaic.org/ada-resources/standards/ada-95-documents/lrm-original/ |access-date=2024-01-19 |website=www.adaic.org}} was published in February 1995, making it 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 language. A Technical Corrigendum to Ada 95 was published in October 2001,[https://www.iso.org/standard/35451.html ISO/IEC 8652:1995/Corr 1:2001][http://www.adaic.org/standards/95lrm/html/RM-TTL.html Ada 95 RM with TC 1] and a major Amendment, ISO/IEC 8652:1995/Amd 1:2007 {{Cite web |last= |title=ISO/IEC 8652:1995/Amd 1:2007 |url=https://www.iso.org/standard/45001.html |access-date=2024-01-19 |website=ISO |language=en}}{{Cite web |title=Ada Reference Manual, ISO/IEC 8652:2007(E) Ed. 3 |url=https://www.adaic.org/resources/add_content/standards/05rm/html/RM-TTL.html |access-date=2024-01-19 |website=www.adaic.org}} was published on March 9, 2007, commonly known as Ada 2005 because work on the new standard was finished that year.

At the Ada-Europe 2012 conference in Stockholm, the Ada Resource Association (ARA) and Ada-Europe announced the completion of the design of the latest version of the Ada language and the submission of the reference manual to the ISO/IEC JTC 1/SC 22/WG 9 of the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) for approval. ISO/IEC 8652:2012{{Cite web |last= |date=2013-03-28 |title=ISO/IEC 8652:2012 |url=https://www.iso.org/standard/61507.html |access-date=2024-01-19 |website=ISO |language=en}}(see [https://www.adaic.org/resources/add_content/standards/12rm/html/RM-TTL.html Ada 2012 RM]) was published in December 2012, known as Ada 2012. A technical corrigendum, ISO/IEC 8652:2012/COR 1:2016, was published {{Cite web |last= |title=ISO/IEC 8652:2012/Cor 1:2016 |url=https://www.iso.org/standard/69798.html |access-date=2024-01-19 |website=ISO |language=en}}(see [http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-TTL.html RM 2012 with TC 1]).

On May 2, 2023, the Ada community saw the formal approval of publication of the Ada 2022 edition of the programming language standard.

Despite the names Ada 83, 95 etc., legally there is only one Ada standard, the one of the last ISO/IEC standard: with the acceptance of a new standard version, the previous one becomes withdrawn. The other names are just informal ones referencing a certain edition.

Other related standards include ISO/IEC 8651-3:1988 Information processing systems—Computer graphics—Graphical Kernel System (GKS) language bindings—Part 3: Ada.

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 from or inspired by Pascal.

= "Hello, world!" in Ada =

A common example of a language's syntax is the "Hello, World!" program:

(hello.adb)

with Ada.Text_IO;

procedure Hello is

begin

Ada.Text_IO.Put_Line ("Hello, world!");

end Hello;

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

gnatmake hello.adb

= 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;

Important to note: Day_type, Month_type, Year_type, Hours are incompatible types, meaning that for instance the following expression is illegal:

Today: Day_type := 4;

Current_Month: Month_type := 10;

... Today + Current_Month ... -- illegal

The predefined plus-operator can only add values of the same type, so the expression is illegal.

Types can be refined by declaring subtypes:

subtype Working_Hours is Hours range 0 .. 12; -- at most 12 Hours to work a day

subtype Working_Day is Weekday range Monday .. Friday; -- Days to work

Work_Load: constant array(Working_Day) of Working_Hours -- implicit type declaration

:= (Friday => 6, Monday => 4, others => 10); -- lookup table for working hours with initialization

Types can have modifiers such as limited, abstract, private etc. Private types do not show their inner structure; objects of limited types cannot be copied.{{cite web |title=Ada Syntax Card |url=http://www.digilife.be/quickreferences/QRC/Ada%20Syntax%20Card.pdf |access-date=28 February 2011 |archive-url=https://web.archive.org/web/20110706133825/http://www.digilife.be/quickreferences/QRC/Ada%20Syntax%20Card.pdf |archive-date=6 July 2011}} Ada 95 adds further features for object-oriented extension of types.

= 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 is not equal to b, loop.

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;

for aWeekday in Weekday'Range loop -- loop over an enumeration

Put_Line ( Weekday'Image(aWeekday) ); -- output string representation of an enumeration

if aWeekday in Working_Day then -- check of a subtype of an enumeration

Put_Line ( " to work for " &

Working_Hours'Image (Work_Load(aWeekday)) ); -- access into a lookup table

end if;

end loop;

= Packages, procedures and functions =

Among the parts of an Ada program are packages, procedures and functions.

Functions differ from procedures in that they must return a value. Function calls cannot be used "as a statement", and their result must be assigned to a variable. However, since Ada 2012, functions are not required to be pure and may mutate their suitably declared parameters or the global state.{{cite web |title=Subprograms |url=https://learn.adacore.com/courses/intro-to-ada/chapters/subprograms.html#function-calls |website=learn.adacore.com |publisher=AdaCore |access-date=14 April 2024}}

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 body (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;

-- package initialization executed when the package is elaborated

begin

while i < Number'Last loop

Print_and_Increment (i);

end loop;

end Example;

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

gnatmake -z example.adb

Packages, procedures and functions can nest to any depth, and each can also be the logical outermost block.

Each package, procedure or function can have its own declarations of constants, types, variables, and other procedures, functions and packages, which can be declared in any order.

= Pragmas =

A pragma is a compiler directive that conveys information to the compiler to allow specific manipulating of compiled output.{{cite web |url=http://archive.adaic.com/standards/83lrm/html/lrm-02-08.html#2.8 |title=Ada 83 LRM, Sec 2.8: Pragmas |publisher=Archive.adaic.com |access-date=2014-01-27}} Certain pragmas are built into the language,{{cite web |url=http://archive.adaic.com/standards/83lrm/html/lrm-B.html |title=Ada 83 LRM, Appendix/Annex B: Predefined Language Pragmas |publisher=Archive.adaic.com |access-date=2014-01-27 |archive-url=https://web.archive.org/web/20120206005541/http://archive.adaic.com/standards/83lrm/html/lrm-B.html |archive-date=2012-02-06}} while others 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 instead of a function call (as C/C++ does with inline functions).

= Generics =

{{excerpt|Generic programming|Generics in Ada}}

See also

{{Portal|Computer programming}}

  • Ada compilers
  • {{annotated link|ALGOL 68}}
  • {{annotated link|APSE}}
  • {{annotated link|Pascal (programming language)|Pascal}}
  • {{annotated link|Ravenscar profile}}
  • {{annotated link|Smalltalk}}
  • {{annotated link|SPARK (programming language)|SPARK}}
  • {{annotated link|VHDL}}

Notes

{{notelist}}

{{reflist}}

References

= International standards =

= Rationale =

These documents have been published in various forms, including print.

  • {{citation |url=http://archive.adaic.com/standards/83rat/html/Welcome.html |last1=Ichbiah |first1=Jean D. |author-link=Jean Ichbiah |last2=Barnes |first2=John G. P. |last3=Firth |first3=Robert J. |last4=Woodger |first4=Mike |title=Rationale for the Design of the Ada Programming Language |year=1986 |archive-url=https://web.archive.org/web/20070202205233/http://archive.adaic.com/standards/83rat/html/Welcome.html |archive-date=2007-02-02}} Also available [https://apps.dtic.mil/dtic/tr/fulltext/u2/a187106.pdf apps.dtic.mil], pdf
  • {{citation |url=http://www.adaic.org/resources/add_content/standards/95rat/rat95html/rat95-contents.html |last=Barnes |first=John G. P. |title=Ada 95 rationale: the language: the standard libraries |year=1995}}
  • {{citation |url=http://www.adaic.org/standards/05rat/html/Rat-TTL.html |first=John |last=Barnes |title=Rationale for Ada 2005 |orig-date=2005 |year=2006}}

= Books =

{{Refbegin}}

  • {{cite book |last=Booch |first=Grady |author-link=Grady Booch |date=1987 |title=Software Engineering with Ada |url=https://archive.org/details/softwareengineer0002booc |url-access=registration |publisher=The Benjamin/Cummings Publishing Company |location=California |isbn=0-8053-0604-8}}
  • {{cite book |last=Skansholm |first=Jan |title=Ada 95 From the Beginning |year=1996 |publisher=Addison-Wesley |isbn=0-201-40376-5}}
  • {{cite book |last=Gilpin |first=Geoff |title=Ada: A Guided Tour and Tutorial |year=1985 |publisher=Prentice hall |isbn=978-0-13-004045-9}}
  • {{cite book |last=Beidler |first=John |date=1997 |title=Data Structures and Algorithms: An Object-Oriented Approach Using Ada 95 |publisher=Springer-Verlag |isbn=0-387-94834-1}}
  • {{cite book |last=Gonzalez |first=Dean W. |author-link=Dean W. Gonzalez |date=1991 |title=Ada Programmer's Handbook |publisher=Benjamin-Cummings Publishing Company |isbn=0-8053-2529-8}}
  • {{cite book |last=Ben-Ari |first=M. |author-link=M. Ben-Ari |date=1998 |title=Ada for Software Engineers |publisher=John Wiley & Sons |isbn=0-471-97912-0}}
  • {{cite book |last=Cohen |first=Norman |title=Ada as a Second Language |year=1996 |publisher=McGraw-Hill Science/Engineering/Math |isbn=0-07-011607-5}}
  • {{cite book |last1=Burns |first1=Alan |author-link=Alan Burns (professor) |last2=Wellings |first2=Andy |author2-link=Andy Wellings |title=Real-Time Systems and Programming Languages. Ada 95, Real-Time Java and Real-Time POSIX. |year=2001 |publisher=Addison-Wesley |isbn=0-201-72988-1}}
  • {{cite book |last1=Burns |first1=Alan |author-link=Alan Burns (professor) |last2=Wellings |first2=Andy |author2-link=Andy Wellings |date=1995 |title=Concurrency in Ada |publisher=Cambridge University Press |isbn=0-521-62911-X}}
  • {{cite book |last=Atkinson |first=Colin |title=Object-Oriented Reuse, Concurrency and Distribution: An Ada-Based Approach |year=1991 |publisher=Addison-Wesley |isbn=0-201-56527-7}}
  • {{cite book |last1=Booch |first1=Grady |author-link=Grady Booch |last2=Bryan |first2=Doug |title=Software Engineering with Ada |year=1994 |publisher=Addison-Wesley |isbn=0-8053-0608-0}}
  • {{cite book |last=Jones |first=Do-While |title=Ada in Action: With Practical Programming Examples |year=1989 |publisher=John Wiley & Sons |isbn=0-471-60708-8}}
  • {{cite book |last1=Stubbs |first1=Daniel |last2=Webre |first2=Neil W. |title=Data Structures with Abstract Data Types and Ada |year=1993 |publisher=Brooks Cole |isbn=0-534-14448-9}}
  • {{cite book |last=Ledru |first=Pascal |title=Distributed Programming in Ada with Protected Objects |date=December 1998 |publisher=Dissertation.com |isbn=1-58112-034-6}}
  • {{cite book |last=Culwin |first=Fintan |title=Ada, a Developmental Approach |year=1997 |publisher=Prentice Hall |isbn=0-13-264680-3}}
  • {{cite book |last1=English |first1=John |last2=Culwin |first2=Fintan |title=Ada 95 the Craft of Object-Oriented Programming |date=January 1997 |publisher=Prentice Hall |isbn=0-13-230350-7}}
  • {{cite book |last1=Musser |first1=David R. |last2=Stepanov |first2=Alexander |title=The Ada Generic Library: Linear List Processing Packages |date=24 October 1989 |publisher=Springer-Verlag |isbn=0-387-97133-5}}
  • {{cite book |last=Feldman |first=Michael B. |title=Software Construction and Data Structures with Ada 95 |year=1997 |publisher=Addison-Wesley |isbn=0-201-88795-9}}
  • {{cite book |last=Johnston |first=Simon |title=Ada 95 for C and C++ Programmers |year=1997 |publisher=Addison-Wesley |isbn=0-201-40363-3}}
  • {{cite book |last1=Feldman |first1=Michael B. |last2=Koffman |first2=Elliot B. |date=1992–1993 |title=Ada: Problem Solving and Program Design |isbn=0-201-52279-9 |publisher=Addison-Wesley}} 795 pages.
  • {{cite book |last1=Feldman |first1=Michael B. |last2=Koffman |first2=Elliot B. |author-link=Elliot Koffman |title=Ada 95 |year=1999 |publisher=Addison-Wesley |isbn=0-201-36123-X}}
  • {{cite book |last1=Dale |first1=Nell B. |author-link=Nell B. Dale |last2=Weems |first2=Chip |last3=McCormick |first3=John |title=Programming and Problem Solving with Ada 95 |date=August 1996 |publisher=Jones & Bartlett Publishers |isbn=0-7637-0293-5}}
  • {{cite book |last1=Dale |first1=Nell B. |author-link=Nell B. Dale |last2=McCormick |first2=John |title=Ada Plus Data Structures: An Object-Oriented Approach, 2nd edition |year=2007 |publisher=Jones & Bartlett Publishers |isbn=978-0-7637-3794-8}}
  • {{cite book |last=Krell |first=Bruce C. |title=Developing With Ada: Life-Cycle Methods |year=1992 |publisher=Bantam Dell Pub Group |isbn=0-553-09102-6}}
  • {{cite book |last=Bishop |first=Judy |title=Distributed Ada: Developments and Experiences |date=10 May 1990 |publisher=Cambridge University Press |isbn=0-521-39251-9}}
  • {{cite book |last=Sanden |first=Bo |title=Software Systems Construction With Examples in Ada |year=1994 |publisher=Prentice Hall |isbn=0-13-030834-X}}
  • {{cite book |last=Hillam |first=Bruce |title=Introduction to Abstract Data Types Using Ada |year=1994 |publisher=Prentice Hall |isbn=0-13-045949-6}}
  • {{cite book |last=Rudd |first=David |title=Introduction to Software Design and Development With Ada |year=1994 |publisher=Brooks Cole |isbn=0-314-02829-3}}
  • {{cite book |last=Pyle |first=Ian C. |title=Developing Safety Systems: A Guide Using Ada |year=1991 |publisher=Prentice Hall |isbn=0-13-204298-3}}
  • {{cite book |last=Baker |first=Louis |title=Artificial Intelligence With Ada |year=1989 |publisher=McGraw-Hill |isbn=0-07-003350-1}}
  • {{cite book |last1=Burns |first1=Alan |author-link=Alan Burns (professor) |last2=Wellings |first2=Andy |author2-link=Andy Wellings |title=HRT-HOOD: A Structured Design Method for Hard Real-Time Ada Systems |year=1995 |publisher=North-Holland |isbn=0-444-82164-3}}
  • {{cite book |last1=Savitch |first1=Walter |last2=Peterson |first2=Charles |title=Ada: An Introduction to the Art and Science of Programming |year=1992 |publisher=Benjamin-Cummings Publishing Company |isbn=0-8053-7070-6}}
  • {{cite book |last=Weiss |first=Mark Allen |title=Data Structures and Algorithm Analysis in Ada |year=1993 |publisher=Benjamin-Cummings Publishing Company |isbn=0-8053-9055-3}}
  • {{cite book |last=Ledgard |first=Henry |title=Ada: An Introduction |year=1983 |publisher=Springer-Verlag |isbn=0-387-90814-5|edition=second }}
  • {{cite book |editor-last=Bjørner |editor-first=Dines |editor2-last=Oest |editor2-first=Ole N. |date=1980 |title=Towards a Formal Description of Ada |publisher=Springer-Verlag |location=London |isbn=3-540-10283-3}}

{{Refend}}

Further reading

  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |date=2024 |title=Programming in Ada 2022 |publisher=Cambridge University Press |isbn=978-1-009-56477-9}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |date=2014 |title=Programming in Ada 2012 with a Preview of Ada 2022 |publisher=Cambridge University Press |isbn=978-1-009-18134-1}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |date=2014 |title=Programming in Ada 2012 |publisher=Cambridge University Press |isbn=978-1-107-42481-4}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |date=2006 |title=Programming in Ada 2005 |publisher=Addison-Wesley |isbn=0-321-34078-7}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |title=Programming in Ada plus Language Reference Manual |year=1991 |publisher=Addison-Wesley |isbn=0-201-56539-0}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |title=Programming in Ada 95 |year=1998 |publisher=Addison-Wesley |isbn=0-201-34293-6}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |date=1997 |title=High Integrity Ada: The SPARK Approach |publisher=Addison-Wesley |isbn=0-201-17517-7}}
  • {{cite book |last=Barnes |first=John |author-link=John Barnes (computer scientist) |date=2003 |title=High Integrity Software: The SPARK Approach to Safety and Security |publisher=Addison-Wesley |isbn=0-321-13616-0}}