With 500 hours and a web server I originally wrote in C++ now written in Ada it isn't all roses. So here is all that I found ugly in my experience with Ada. These are not terrible things but they are just ugly!
In any Ada line, what follows -- is a comment
and that is the only way to comment so making
a block comment simply involves starting every line with --
. This can be tedious and stupid.
Of course C uses /* comment */
which can extend a comment over many lines and is very
useful for commenting out large blocks of code from time to time which is an absolutely necessary part of programming.
This is regrettably absent in Ada on the basis that it is possible to forget that code was commented
out. I do not agree. Some editors will allow you to add --
to a highlighted collection
of lines.
In Ada one ends up using if false then
and end if;
as a way to comment out
blocks of code. This is far more dangerous than /* */
because it looks like working
code in the IDE and is so very easily overlooked. A commented out block is easily spotted as its usually
grey or some odd colour.
When programming I also use /* */
as a way of bringing in a piece of text I need to refer to
while working, it may not be valid code at all, so not having block comment is extraordinarily annoying and quite unnecessary.
Block comments are needed and they should be nestable. i.e. /* /* */ */
should be fine so you can comment
out a whole block of code without problems with the comments actually in that code. In Ada you end up writing if False then
where you are quite likely to leave it in by accident. Or perhaps you remove the wrong end if;
In C we have x++;
and x+=2;
etc. In Ada there is no such luxury and you
are stuck with x:=x+1;
and x:=x+2;
If the variable name is a long one
this can be a bit much. The Ada argument is that x++
is an operation with serious consequences
and should therefore be unmissable. Personally although I grumbled I really found this effected
very little of the code in the end as incrementing is not so common.
Although arrays can have any range you like and so can start at 0 if you wish, the three types of string library in Ada are indexed from 1. Although to the common man the 1st item is the 1st item, for us programmers we know that an index is normally an offset into a piece of memory and so offset 0 is the offset to the 1st position in the memory.
In the 1st year of a baby's life how old is it? Zero.
Defining a 256 byte circular buffer and indexing from 0..255 means the index nicely fits in a byte. Not so 1..256.
Also when breaking a string containing a sentence into words. Giving the index in the string to the start of each word and then an offset to the letter in the word. Means if you copy a word at an index you copy offset 0..whatever into another string starting 1..whatever+1 .Not elegant.
Sometimes programs tell you what they want. They clearly want to index from 0 and only the common man indexes from 1. A programmer of very little experience has no problem indexing from 0 always. Ada puts you in the position of mixing both because there are many situations where indexing from 0 is the only way but there are no situations where indexing from 1 is the only way.
I haven't changed my views much from those at 500 hours. The lack of a preprocessor like C/C++ #define #ifdef and all that is a pain in the arse, because they are useful for changing what is compiled by changing a few parameters. I have had to physically comment out debugging code to speed up exectution when a simple #ifdef would have done the job in C/C++. But see my comments in The Good for more about what I do like.
I will still be sticking with Ada for mission critical development work from now on.
OK CORRECTION: I substituted code with something like d:constant integer:=7;
then in the code you can use if d>4 then
then your code and then end if;
. The compiler evaluates the constant expression and doesn't compile the code at all. It recognises code that will never be executed. This is good. SO perhaps I can manage without the pre-processor.