Ada Programming Language Cheatsheet

Ada, a robust and statically-typed programming language, is known for its focus on safety and reliability in critical systems. Whether you’re a seasoned Ada developer or a newcomer, this cheatsheet serves as a handy reference for key Ada features, syntax, and best practices.

Hello, Ada!

with Ada.Text_IO;

procedure Hello is
   Ada.Text_IO.Put_Line("Hello, Ada!");
end Hello;



-- This is a single-line comment

   This is a
   multi-line comment


X : Integer := 42;
Y : Float := 3.14;


Pi : constant Float := 3.14159265359;


Message : constant String := "Hello, Ada!";
Interpolated_Message : String := "The value of X is " & Integer'Image(X) & ".";

Control Flow

If Statement

if X > 10 then
   -- Code here
elsif X < 0 then
   -- Code here
   -- Code here
end if;

Case Statement

case X is
   when 1 =>
      -- Code here
   when 2 | 3 =>
      -- Code here for 2 or 3
   when others =>
      -- Code here for other cases
end case;


while X > 0 loop
   -- Code here
   X := X - 1;
end loop;

Procedures and Functions

Procedure Declaration

procedure Print_Sum(X, Y : Integer) is
   Ada.Text_IO.Put_Line("Sum: " & Integer'Image(X + Y));
end Print_Sum;

Function Declaration

function Add(X, Y : Integer) return Integer is
   return X + Y;
end Add;

Exception Handling

   Result : Integer;
   Result := X / Y;
   when Constraint_Error =>
      Ada.Text_IO.Put_Line("Division by zero not allowed.");

Records and Enums

Record Declaration

type Point is record
   X, Y : Float;
end record;

Enum Declaration

type Result_Type is (Ok, Err);

Tasking (Concurrency)

task type My_Task;
task body My_Task is
   -- Code for the task
end My_Task;

This Ada programming language cheatsheet provides a quick reference for developers working with Ada. Whether you’re building safety-critical systems or exploring the language for the first time, use this guide to enhance your Ada programming experience. For more in-depth information, refer to the official Ada documentation and community resources


Why choose Ada for programming?

Ada is chosen for its emphasis on safety and reliability, making it a preferred language for critical systems. Its strong typing and focus on preventing errors contribute to the language’s reputation for building robust applications.

How is Ada different from other programming languages?

Ada stands out with its built-in support for safety-critical systems, strong typing, and concurrency features. It offers a unique balance between performance and reliability, making it distinct from other general-purpose languages.

Can Ada be used for modern software development?

Absolutely. While initially designed for defense and aerospace applications, Ada has evolved to support modern software development needs. Its features, including object-oriented programming and tasking, make it suitable for a wide range of applications.

Is there an active Ada community for support and collaboration?

Yes, the Ada community is active and supportive. Resources such as forums, online communities, and documentation are readily available. Engaging with the community is a great way to seek assistance, share experiences, and stay updated on Ada development.

How does Ada handle concurrency and parallelism?

Ada has built-in support for tasking, making it well-suited for concurrent and parallel programming. Tasks in Ada can run concurrently, and the language provides mechanisms for synchronization and communication between tasks, facilitating the development of efficient and scalable concurrent applications.