2020-07-31

Ada++ what?

Not very much time ago I commented on a post on LinkedIn. The post promoted the “Ada++” language as some sort of better Ada. As an Ada hobby newcomer who began to like the language very much (and who started to consider C++ acceptable in its modern revisions, and yet continues to think not very much of that really important and powerful language), I felt horrified. Ada isn’t perfect, nothing is perfect, but the comment made me think it was almost all because of the syntax. What’s wrong with Ada’s syntax? According to me, nothing; and on the other side there’s C++, which to me is a syntax nightmare.

One month later or so, I stumbled on that comment again and took a look (again!) to the Ada++ website. Looking around… again… I confirmed my first impression that the idea is horrorful, even if it would about syntax only.

Do we want a C++-syntax-like language? What’s the value in this? Will C++ developer feel more comfortable? Why not a C++ada language where C++ imitates Ada’s syntax, just to make Ada developers more comfortable with C++…?

Reading the tutorial

Let’s start with a tutorial

The following original tutorial was written by Quentin Ochem and published by AdaCore and has been adapted to use the optional Ada++ syntax.

Good news: the Ada++ syntax is optional. It means there must be more in this Ada++, as suggested by the original poster on LinkedIn. Doesn’t it?

About the rest, is it really nothing more than the original Ada tutorial with the new (optional) syntax used instead of the good old one?

We have spec and body files, as in Ada. Of course: it’s Ada, indeed.

with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
begin
   Put_Line ("Hello World");
end Main;

This is the Hello world in the original tutorial. Now admire the value of the change 😏

    use Ada.Wide_Text_IO;
    proc Main:
    {
      Put_Line ("Hello World");
    }

Of course you can use Wide_Text_IO also in Ada; so, this is not the difference. The first actual difference is that you don’t need with — and that’s still good: writing with X; use X is really a reason to start a new language. Anyway, sarcasm apart, it’s just syntax.

And what’s next? Just syntactical changes… among these: everyone love curly brackets and hate words, you know; but it’s still syntactical sugar… Nothing that shows the value of Ada++.

And since the original tutorial is about learning Ada, I suspect it doesn’t go very much beyond

  • pointlessly shortening keywords (proc instead of procedure, pkg instead of package, even priv instead of private, where C++ uses the full word private…)
  • replacing keywords with symbols (: can now be replaced with a colon… I was waiting for it since eons! At last!!!)
  • adding operators like ++, to be used instead of A := A + 1

Luckly body is still body and not bdy!

The original tutorial says something not 100% correct about & and |, and that was copied in the “new” tutorial:

It’s more customary to use && and || in C++ and Java than & and | when writing boolean expressions. The difference is that && and || are short-circuit operators, which evaluate terms only as necessary, and & and | will unconditionally evaluate all terms.

Indeed, & and | aren’t logical operators: they are bitwise operators. They could work as expected when used in a boolean way, but it is a little bit “risky” to use them mindlessly in the same way you would do with the logical operators && and ||.

Anyway, … the tutorial doesn’t show much more. It ends with More coming soon!

Finding more

Is it all there in the tutorial? Just syntax so far. Let’s dig more. Let’s follow the docs link.

Besides the “Ada++ Issue/Feature” list below, Ada++ behaves like Ada since it is based on the GNAT Ada compiler.

So, Ada++ is Ada with “syntactic sugar” (sugar according to its creators…)? It seems so.

Let’s see the items in the docs and comment briefly on them.

  • Support LLVM
  • Optional curly braces instead of begin end
    • Just syntax; no added value
  • New subtypes which appreviate [sic!] certain common types
    • Pointless: a programmer who often needs those “appreviation” will forge a package containing them; and what about using what Interfaces offers?
  • abbreviated form for pragma
    • just syntax; no added value
  • abbreviated form for is (that is, :)
    • just syntax; no added value
  • ++, +1 and -1 operators
    • just syntax; no added value
  • raise when construct
    • no actual example given, but this addition sounds the only one which can really give something

Final words

That’s all. So far, this Ada++ seems to give just an optional “transformative” syntax, with only one exception. Not enough.

And beyond that, this new optional syntax is bad, in my opinion. There’s no value in shortening keywords per se (the priv vs private is just ridiculous…); moreover, do we need another curly-brackets-syntax-like language? Is a language “better” if it imitates traits of the C syntax?

I don’t mean to be rude and harsh, but this Ada++ seems a waste of time. Energies could be spent better proposing valuable changes to whoever is in charge of the standardization of Ada. So far, only raise when seems to be something worth the time and the shot.

No comments:

Post a Comment