A Modern Syntax for Ada
by Fabien Chouteau , Yannick Moy , Vasiliy Fofanov , Nicolas Setton –
One of the most criticized aspect of the Ada language throughout the years has been its outdated syntax. Fortunately, AdaCore decided to tackle this issue by implementing a new, modern, syntax for Ada.
The major change is the use of curly braces instead of begin/end. Also the following keywords have been shortened:
- return becomes ret
- function becomes fn
- is becomes :
- with becomes include
For instance, the following function:
with Ada.Numerics;
function Fools (X : Float) return Float is
begin
return X * Ada.Numerics.Pi;
end;
is now written:
include Ada.Numerics;
fn Fools (X : Float) ret Float :
{
ret X * Ada.Numerics.Pi;
};
This modern syntax is a major milestone in the adoption of Ada. John Dorab recently discovered the qualities of Ada:
I have an eye condition that prevents me from reading code without curly braces. Thanks to this new syntax, I can now benefit from the advanced type system, programming by contract, portability, functional safety, [insert more cool Ada features here] of Ada. Also, it looks like most other programming languages, so it must be better.
This new syntax is also a boost in productivity for Ada developers. Mr Fisher testifies:
I write at around 10 lines of code per day. With this new syntax I save up to 30 keystrokes. That’s at a huge increase to my productivity! The code is less readable for debugging, code reviews and maintenance in general, but I write a little bit more of it.
The standardization effort related to this new syntax is expected to start in the coming year and to last a few years. In order to allow early adopters to get their hands on Ada without having to wait for the next standard, we have created a font that allows you to display Ada code with the new syntax:
The font contains other useful ligatures, like displaying the Ada assignment operator “:=” as “=”, and the Ada equality operator “=” as “==”. It was created based on Courier New, using Glyphr Studio and cloudconvert. It’s work in progress, so feel free to extend it! It is attached below.
In the future, we also plan to go beyond a pure syntactic layer with Libadalang. For example, we could emulate the complex type promotions/conversions rules of C by inserting Unchecked_Conversion calls each time the programmer tries to convert a value to an incompatible type. If you have other ideas, please let us know in the comments below!
Attachments
- Ada For C Programmers Font - 36.99 kB