Conditional expressions in Ada 2012

It appears that Ada 2012 will get conditional expressions:

The last link is the most interesting, in my humble opinion, not least because it’s always interesting to experience the big wigs of Ada getting down and dirty over interesting subjects.

I must admit that I _personally_ do not like conditional expressions. I’ve used them a lot in my PHP code, and only on rare occassions do they make the code more readable. Sure, they look “cool” when you write them and they do save a bit of typing, but they also make for bad reading when you have to make changes to the code 2 years later. Especially because they are easy to abuse, turning them into unreadable monsters.

What attracted me to Ada in the first place was that it didn’t allow me to write insanely terse C style code. Ada felt a bit more like an actual language (to the extent that that is possible when reading code), and that instantly clicked with me.

But of course I don’t have to use those conditionals in my code, or I could just use them sparingly. There are two problems with that:

  1. I might not use them, but I might end up depending on code written by people who do use them.
  2. I’m weak and lazy. When hammering out some new code, I just might succumb to the temptation of a fast one-liner conditional, instead of a larger if/else block.

Now I’m sure Ada 2012 will bring many wonderful things to the language, but I strongly feel that this specific thing is an abomination that does not belong in Ada. Code like this is just plain ugly.

This question was put forward on IRC (#ada):

I just wonder how much of our horror and despair is because these new features are really Bad Ideas, and how much is us just being old sticks in the mud?

I might be an old stick in the mud, but I don’t think that’s why I dislike this addition. It is my experience (~10 years) with PHP, a language that have conditional expressions, that makes me want to run away screaming at the top of my lungs “DON’T DO IT! PLEASE, FOR THE LOVE OF EVERYTHING THAT IS SACRED AND HOLY. DON’T DO IT!”.

But I might be wrong about conditional expressions in Ada. It wouldn’t be the first time. Maybe they will turn out to be a killer-feature, attracting all sorts of positive attention. Time will tell.

Leave a Reply