-
Ada is strongly typed: each variable has a specific type, reducing runtime errors.
-
Supports enumerated types, derived types, and constrained types.
Example:
type Week_Day is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
- Designed for critical systems (aerospace, defense, space).
- Performs strict compile-time and runtime checks (range checks, overflows, etc.).
-
Code is organized using packages.
-
A package consists of:
- a specification (interface)
- a body (implementation)
Example:
package Maths is function Square (X : Integer) return Integer; end Maths; package body Maths is function Square (X : Integer) return Integer is begin return X * X; end Square; end Maths;
-
Robust error handling through exceptions.
Example:
begin -- code exception when Constraint_Error => -- error handling end;
-
Native support for multitasking using tasks, rendezvous, and protected objects.
-
Enables deterministic concurrent programming.
Example:
task type Sensor is entry Read; end Sensor;
-
Supports preconditions, postconditions, and invariants.
-
Encourages design by contract.
Example:
function Root (X : Float) return Float with Pre => X >= 0.0, Post => Root'Result ** 2 <= X;
- ISO/IEC standardized language.
- Well-suited for real-time and embedded systems.
- Inspired by Pascal, with explicit structure (no braces).
- Encourages readable and maintainable code.
procedure Hello is
begin
Put_Line("Hello, Ada!");
end Hello;