Worries about the future with what adacore has in store

Hi, I watched High Integrity Technology Update | April 2024 and almost got a heart attack. Four things, which I memefied to better convey my feelings, appalled me. Pattern matching I could see the interest… even thoug they didn’t provide a single convincing use case yet. But the rest ? Constructors ? String interpolation ? Classes ? These things never had anything to do in Ada, were never needed, or were explicitely rejected from the very early beginning, in favor of a cleaner design that did not blend orthogonal notions such objects and encapsulation.

I might be a beginner, but I’m 30, with common sense, a degree in history and notions of psychology. I believe the situation is identical to a story 10 to 15 years ago, with an exacting but consistent natural diet, with sound principles, that wasn’t appealing to many people because it demanded from its practionners discipline and thinking differently. Then to make more bucks the people which due to circumstances got a virtual monopoly on the brand opted to align themselves with mainstream dietetics in language, something already worrying… then remove all meat from their catalogue to please their prospective vegan customers… then add bloody vitamin complements. To appeal to the mythical larger audience. Adacore is defiling Ada. We like it because of the philosophy, because and not in spite of it. “string interpolation” belongs to bash scripts. Just to avoid writing a few 'Image, seriously ?

It’s pointless as well: why would C or C++ programmers bother with a botched C++ clone with lots of verbuous English and a dearth of libraries, when they have the real deal and access to a world of existing C/C++ projects ?

2 Likes

The only one I vehemently disagree with here is local variables without the declare block. I think it’s confusing and actively goes against the philosophy of the language.

I’m actually excited about pattern matching and have been following the rfc with baited breath. It’s something that would have made my life easier with things like parsers and one argument against using Ada I’ve heard is that it doesn’t have pattern matching at the level of other languages. Maybe now I can stop nesting switch statements.

Tagged types in ada always felt hacky for me. I use them heavily and always felt it kind of weird that I had to have procedures that are accessible via the dot-operator had to be directly after the type’s finished definition, because now I’m structuring my header files in rigid ways. At least if they move to this actual OOP syntax, I can nest the dang things correctly into the type and properly scope those functions to the type.

I’m not against string interpolation, and could go either way as long as I’m not taking a performance hit (strings in ada have always felt incredibly fast). It depends on which of the following lines of code you’d rather have:

Put_Line ("The name is " & Name & " and the sum is " & Integer(X + Y)'Image & ".");

vs

Put_Line (f"The name is {Name} and the sum is {X + Y}.");

I’m neutral with constructors and destructors; we already have controlled types so I’m not sure what the use case is. I have over 20 “from_” in my money library with tons of various overriding and I guess using something like T1’Make(…) instead could work. I’d rather be explicit though. I hope these constructors are at least using the stack…

P.S. When I read the title, I thought you were going to complain about things like this:

2 Likes

Actually I read that a few hours later :rofl: I see they’ve been pandering to all kinds of trendy languages for many years by now. But while typically those efforts fail lamentably, I wouldn’t mind their business practices wouldn’t bother me much if they treated the language with more respect.

Put_Line ("The name is " & Name
& " and the sum is " & Integer(X + Y)'Image & ".");

Yes this above is much clearer than showing {} inside, and that new “f” completely at odd with the rest. I’m absolutely certain no serious or long term Ada programmer ever wished for whatever they brought in, imitating whichever unprofessional functional or script language.
I think the need for constructors must parallel the removal of controlling returns… but then we loose flexibility. An aspect would suffice to indicate a controlling result/constructor status, there is no need to ape C++. They just aim to make a more marketable product, or so they think.

1 Like

Well I guess that means I’m not a serious programmer, clearly 30 years is not enough experience.
I prefer the string interpolation way both for readability and for ease of use.

2 Likes

I personnaly dislike both syntax.

  • Strings constructions like "The name is " & Name & " and the sum is " & Integer(X + Y)'Image & "." are not translatable.
  • Interpolated strings can’t be translated also.

Outside debugging, I can’t see a use case for such syntaxes.

I just spoke my mind, no offense. I attack dangerous opinions, not people… One can be brilliant and wrong. I just can’t understand “fixing” something that’s not broken for a very strange sense of convenience. Perhaps you have been taught on other languages or used them preferently ?

Interpolated strings can’t be translated also

What do you mean by translatable ? Like, from English to French ? Or one unicode format to another ?

I mean translated to the language of the user (french, chinese…).

Thought so. What does that have to do with syntax, and what’s wrong with this

type Lang is (French, English, Chinese, Mandalorian);
function Translate (English : String; Current_language: Lang) return String;

This doesn’t work in practice with interpolated strings.

The f-string is first read as a Wide_Wide_String, processed, interpolated and then converted to the expected type, a String in your example (link to the RFC). Finally, the result of the interpolation is passed to the Translate function. Good luck to do something useful with it in the function.

Most translation tools use catalogs of (complete sentence) strings with placeholders for parameters to be replaced. A string is first translated and then processed, not the contrary. And it’s already hard to do good translations that way…

The problem with mingling declarations and executable statements is what can be referenced in exception handlers. No doubt AdaCore have a rule about that for their language extension, but I can’t conceive of one that would make the combination of this feature and exception handlers useful. Added to the fact that such mingling makes the code more difficult to understand, by making declarations harder to find, and I can see no case for allowing this.

1 Like

No I mean with the normal strings. Of course translation tools would use dictionaries. Otherwise you would need a real automatic translation with an LLM… What else would you expect ? My only grip with String is the limitation to ISO-8859-1 there is in GNAT, so that you can’t naturally just write ‰碱螽 in it like you can do in almost every graphical application on linux now (ctrl-u). gnatmake works fine, but alr run suffers from the same issue too, even though it’s not graphical… go figure. We should be able to write any unicode symbol in string literals and comments, and the compiler should figure out itself what kind of character it should be, normal or wide or wide wide.

I think the main use case (aside from being familiar to others from other languages) is adding construction/destruction to existing tagged types. Since they already have a base type you cannot extend them off of any controlled type. There are all work around but all have some kludge aspect to them and don’t fully provide the desired full functionality.

Also, if you dislike inheritance altogether (a lot of folks dislike it), having attribute or aspect based constructors/destructors is really nice. It means you aren’t forced to use inheritance that you would not otherwise have needed.

2 Likes

Could you provide an exemple of something normal functions or a mixin and an access discriminant can’t easily do ? I could learn a thing or two :slight_smile:

Normal functions aren’t called automatically like Initialize and Finalize are. A Mixin doesn’t allow you to properly add them so that future descendants can also override them. Additionally using a mixin can cause some logic errors/bugs because a mixin would only call Finalize during the component finalization process meaning you could run into cases where components of descendants where already finalized prior to your Finalize being called, meaning your finalize could be operating on already finalized variables.

See: Extending a third party tagged type while adding finalization - Jere

In particular:

2 Likes

Wouldn’t to allow initialize/etc for already existing tagged types do the same ? There’s an rfc replacing Controlled and Limited_Control with interfaces, and another with aspects (gnat extension) but then they explicitely exclude it for non-base types… or I might be confused.

They currently don’t allow this in Ada. Once you have an existing tagged type, if it wasn’t extended from a Controlled type originally you cannot add it in in an extendable manner (if you are working with 3rd party libraries). Now if Ada added a controlled interface, then that would definitely solve my problem. They haven’t and I don’t think it is currently planned (maybe it is? I haven’t checked the AI docket in a bit). But either an interface version or the atribute constructors/destructors would work for my use case (if either existed).

Using the issues’ search engine isn’t easy, but it’s there, and I remember the restriction well. Gnat extension also states it:

The Finalizable aspect can be applied to any record type […]. The only restriction is that the record type must be a root type, in other words not a derived type.

I was more referring to the feature they mentioned in the video ('Constructor and 'Destructor). The Finalizable aspect is a different thing from that. They may have the same restrictions for both, but I did not see it. It would be a shame though if they do have the restrictions on both.

Also keep in mind that the issues on the github are for discussion. There’s no guarantee that any one issue gets implemented or even implemented as originally requested.

For issues currently under consideration:

In particular the Ada 2022 Technical Corrigendum Issues section as those are the next batch likely to make it into the language. I haven’t looked through them to see if it is in there (I cannot get zip files here easily).

1 Like

I was refering to these :grin:. Your exemple with out-of-order initialization/finalization was very informative. I can see that one would want to fix a precise order somehow.

Gotcha! I got confused cause your OP and meme picture were highlighting the method from the video. Sorry about that!

I think I found the github issue:

But it does allow for derived types.

But maybe the discussion for the issue addresses a change in that. I didn’t read through fully yet.