โœˆ๏ธ

Ada Cheat Sheet

Built for the U.S. Department of Defense specifically to eliminate the kinds of bugs that cause catastrophic failures โ€” Ada is still mandated or heavily used in avionics, air-traffic control, railway signaling, and defense systems where a crash isn't an inconvenience, it's a disaster.

๐Ÿ“ Reference page only โ€” Ada's real value is its certified, safety-critical toolchains (used for DO-178C aerospace certification, for example), which aren't something a free browser sandbox can meaningfully replicate. For hands-on practice, GNAT Community (the free open-source Ada compiler) is the standard way to actually build and run these examples.
Jump to: Your first programStrong typingif / else LoopsProcedures & functionsPackages

Your first program

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

Strong typing

Ada's defining feature โ€” you can define exactly what values are legal for a type, and the compiler enforces it. This is a huge part of why it's trusted for safety-critical code.

type Altitude is range 0 .. 45000;   -- illegal values are a compile error, not a runtime bug
Cruise_Alt : Altitude := 35000;

if / else

if Age >= 18 then
   Put_Line("Adult");
elsif Age >= 13 then
   Put_Line("Teen");
else
   Put_Line("Child");
end if;

Loops

for I in 1 .. 5 loop
   Put_Line(Integer'Image(I));
end loop;

while N > 0 loop
   Put_Line(Integer'Image(N));
   N := N - 1;
end loop;

Procedures & functions

function Add(A, B : Integer) return Integer is
begin
   return A + B;
end Add;

Packages

Ada's module system โ€” groups related types, procedures, and functions with a clean public/private separation.

package Geometry is
   function Area(Width, Height : Float) return Float;
end Geometry;

package body Geometry is
   function Area(Width, Height : Float) return Float is
   begin
      return Width * Height;
   end Area;
end Geometry;
โ† See government/defense IT career paths