Its common these days for students to learn C++ , and many apps are indeed written in C++ as a side effect of the above endless circle.
However, The truth is C++ is not all that great really.
**But why Ada..**
Over the next few blogs I am going to just throw(hehe) out a few examples and you can see for yourself.
The important thing here is to learn both before making calls on what is better for what. Clearly everything has its place. Although its good to know a little more then just past your nose ;)
Here goes...
Exception handling;
As you know exception handling consists of three components, the
exception (derr), raising the exception and handling the exception.
However, In C++ there is no exception type. When you raise an
exception you pass out any sort of type while selecting the exception
on its type. In Ada, there is a 'psuedo-type' for exceptions.
So here is some example code:
In C++
try {
my_func();
} catch (declaration) {
clean_up();
}
In Ada
begin
my_func();
exception
when ident => clean_up();
when others => clean_up();
end;
OK, now here is a example where we call a function which we know may
raise a particular exception. Although it _may_ raise one that we
don't know about so we *must* pass everything else back up to whoever
called the function.
try {
func_call();
} catch (const char* string_exception) {
if(!strcmp(string_exception, "what_we_are_look_for")) {
handle_it();
} else {
throw;
}
} catch (...) {
throw;
}
OK, now in Ada:
begin
func_call();
exception
when what_we_are_look_for => handle_it;
when others => raise;
end;
Yes it even looks better !
This shows how much safer the Ada version is, we know exactly what we
are waiting for and can immediately process it. In the C++ case, all we
know is that some kind of exception occured of type 'const char*' had
been raised, we must then check it still further before we can handle
it !
I will try to keep these short, so that is it for now.
Regards,
Edward O'Callaghan.