ada 202x a broad overview of relevant news
TRANSCRIPT
Ada 202xA broad overview of relevant news
1st November, 2016
HIS 2016
Altran UK Limited
Florian Schanda
1
Introduction
Apologies
Anish Mohammed (Ripple Labs) could sadly not attend - this isnot his talk.
Instead some news from the Ada language design group!
Overall direction
New language features
Potential language features
2
Ada 202xBroad direction
’95 Polymorphism, Protected objects, and many more
2005 Interfaces, Ravenscar, Assertions, Containers
2012 Contracts (and richer expressions)
202x Parallelism (and richer expressions)
3
Ada 202xBroad direction
’95 Polymorphism, Protected objects, and many more
2005 Interfaces, Ravenscar, Assertions, Containers
2012 Contracts (and richer expressions)
202x Parallelism (and richer expressions)
3
Ada 202xBroad direction
’95 Polymorphism, Protected objects, and many more
2005 Interfaces, Ravenscar, Assertions, Containers
2012 Contracts (and richer expressions)
202x Parallelism (and richer expressions)
3
Ada 202xParallelism
Todays architectures are increasingly multi-core
GPU based solutions are an extreme example
It’s notoriously difficult to get this right
Ada should make this easy!
4
Ada 202xParallelism
Todays architectures are increasingly multi-core
GPU based solutions are an extreme example
It’s notoriously difficult to get this right
Ada should make this easy!
4
Ada 202xParallelism
The parallel block statement:
parallel
P := Compute_Prime (Bits => 4096,
RNG => "/dev/random");
and
Q := Compute_Prime (Bits => 4096,
RNG => "/dev/random");
end parallel;
parallel
N := P * Q;
and
Phi := (P - 1) * (Q - 1);
end parallel;
parallel
Public_Key := Make_Public_Key (N, Phi);
and
Private_Key := Make_Private_Key (N, Phi);
end parallel;
5
Ada 202xParallelism
Something similar is planned for parallel loops. Three parts:
Optional declaration of storage for each chunk
Loop
Optional reduction
parallel
Sum : array (<>) of Integer := (others => 0);
−− Size of loop array depends on number of chunksfor I in 1 .. 1_000_000 loop
Sum (<>) := Sum (<>) + A (I); −− Write to the current chunk’s sumthen
Answer := 0;
for Value of Sum loop
Answer := Answer + Value;
end loop;
end loop;
6
Ada 202xExpressions
Short-hand for the left-hand-side of an assignment:
Database.Current_Instance (N). Usage_Count := @ + 1;
More flexible than += or similar short-hands found in otherlanguages:
Arr (X + Y) := (if @ < Integer ’Last
then @ + 1
else Integer ’First);
7
Ada 202xExpressions
Short-hand for the left-hand-side of an assignment:
Database.Current_Instance (N). Usage_Count := @ + 1;
More flexible than += or similar short-hands found in otherlanguages:
Arr (X + Y) := (if @ < Integer ’Last
then @ + 1
else Integer ’First);
7
Ada 202xExpressions
Delta aggregates replace Spark update expressions:
procedure Adjust (R : in out Record_T;
Fudge : Float)
with Post => R = (R’Old with delta
Low_Bound => Fudge * R’Old.Low_Bound ,
Hi_Bound => Fudge * R’Old.Hi_Bound );
−− We now know all other fields *do not* change
Also quite useful in non-contract code:
All_Zero : constant Array_T := (others => 0);
Mask : constant Array_T := (All_Zero with delta
A .. B => 1,
C .. D => 1);
8
Ada 202xTasking
New aspect Nonblocking
New aspect Max Entry Queue Length
Extended Ravenscar profile
Multiple entriesRelative delaySupport for Ada.Calendar and implicit heap allocations
9
Ada 202xOther possible features
Let expressions
Lambda functions
Generator subprograms (a limited form of co-routines)
yield 0; −− Return to calling subprogram, resume execution hereyield X;
These are iterable:
for Values of My_Generator loop
−− First we get 0, then we get X, ...
Container aggregates and displays
S : Hash_Set := (X, Y, Z);
P : Hash_Set := (for N in Positive if Is_Prime (N) => N);
10
Ada 202xOther possible features
Let expressions
Lambda functions
Generator subprograms (a limited form of co-routines)
yield 0; −− Return to calling subprogram, resume execution hereyield X;
These are iterable:
for Values of My_Generator loop
−− First we get 0, then we get X, ...
Container aggregates and displays
S : Hash_Set := (X, Y, Z);
P : Hash_Set := (for N in Positive if Is_Prime (N) => N);
10
Ada 202xOther possible features
Let expressions
Lambda functions
Generator subprograms (a limited form of co-routines)
yield 0; −− Return to calling subprogram, resume execution hereyield X;
These are iterable:
for Values of My_Generator loop
−− First we get 0, then we get X, ...
Container aggregates and displays
S : Hash_Set := (X, Y, Z);
P : Hash_Set := (for N in Positive if Is_Prime (N) => N);
10
Ada 202xConclusion
Parallelism
More expressions (better contracts)
Many of these will make it into Spark
11
12