ada 202x a broad overview of relevant news

18
Ada 202x A broad overview of relevant news 1 st November, 2016 HIS 2016 Altran UK Limited Florian Schanda 1

Upload: adacore

Post on 20-Jan-2017

225 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Ada 202x A broad overview of relevant news

Ada 202xA broad overview of relevant news

1st November, 2016

HIS 2016

Altran UK Limited

Florian Schanda

1

Page 2: Ada 202x A broad overview of relevant news

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

Page 3: Ada 202x A broad overview of relevant news

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

Page 4: Ada 202x A broad overview of relevant news

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

Page 5: Ada 202x A broad overview of relevant news

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

Page 6: Ada 202x A broad overview of relevant news

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

Page 7: Ada 202x A broad overview of relevant news

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

Page 8: Ada 202x A broad overview of relevant news

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

Page 9: Ada 202x A broad overview of relevant news

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

Page 10: Ada 202x A broad overview of relevant news

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

Page 11: Ada 202x A broad overview of relevant news

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

Page 12: Ada 202x A broad overview of relevant news

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

Page 13: Ada 202x A broad overview of relevant news

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

Page 14: Ada 202x A broad overview of relevant news

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

Page 15: Ada 202x A broad overview of relevant news

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

Page 16: Ada 202x A broad overview of relevant news

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

Page 17: Ada 202x A broad overview of relevant news

Ada 202xConclusion

Parallelism

More expressions (better contracts)

Many of these will make it into Spark

11

Page 18: Ada 202x A broad overview of relevant news

12