re: Reasons for loving Ada. #1: strong typing VIEW POST

TOP OF THREAD FULL DISCUSSION
re: While you wait for Riccardo to chime in, I think I can answer some of your questions. Ada is general-purpose but is not that comfortable for quick...
 

Thanks for the reply. Those are really great answers.

I've read a bit about Ada and read a whole book on Spark but I've never done a project in either. Do you (or anyone) have an idea how fast you can write a project in Ada vs C/C++?

For example, Let's say I wanted to write a clone of TrueCrypt/VeraCrypt for Debian without looking at the source. Let's further assume that I'm equally proficient in Ada and C/C++. I'm trying to get an idea of how much quality do I need to require from the code to justify the effort of writing in Ada. Does that make sense?

I imagine could quickly pound out a buggy version in C/C++. But the fastest version I could make in Ada would take longer and have fewer bugs than the C/C++ version. And then all the way at the other extreme of quality, I imagine that if I wanted 0.1 defects per KLOC, I could get there faster in Ada than I could in C/C++ (if I could ever get there at all). And at some point, as we move to fewer and fewer defects, those lines cross. Do you (or anyone) have any idea where that might be?

In other words, how much do I need to care about quality to make it worth using Ada? Or is that not true at all? Maybe once you know Ada well, you can write as fast or faster than in C/C++ and lower defect rates are a happy side effect of using the language?

Also, does the equation change if we trade C/C++ with something safer like Java?

Let's see I get the gist of your question.

For an equally proficient Ada/C++ programmer I'd say Ada development speed is the same if not faster. Ada is a bit more verbose, but with a completion editor that's mostly moot, and in any case I feel it would be offset by the gains in debugging time. Ada is not foolproof though, and if you carelessly start to play with pointers you will lose sleep over the same kind of memory corruption errors (I must check Rust for precisely that reason). Dynamic memory management is similar to C++, but using standard containers you can avoid most problems (same as in C++, but still Ada containers have extra checks).

Related: Ada use of the stack is far superior (with its unconstrained/indefinite types), so you can avoid pointers in much more places that would require them in C++. I'd say this is the most jarring part for programmers coming from C/C++, since it has not really an equivalent there (to my knowledge).

If Java enters the picture: you lose somewhat on the efficiency department, but I guess unless doing real-time it won't be a problem. Also, you trade memory corruption for memory leaks in my experience (but I'm not as experienced in Java as in Ada). However, my personal dilemma would mostly be Ada vs Java; I avoid C/C++ if I can (there's too much of it anyway where I cannot choose).

To summarize, if you're equally proficient in Ada/C++/Java:

If a compiled language is a must: Ada unless you need lots of 3rd party libraries that would take a long time to bind/replicate in Ada; in that case C++ with most warnings on. (Gnat has an automatic C binding generator but in my (old) experience it was not yet 100% there).

If interpreted is OK: Java if 3rd party libs needed, Ada if tasking is involved, otherwise down to personal preference (Ada in my case).

Also, another factor against Ada is that the community is (much) smaller, if you want to attract collaborators. On the other hand, there is people very devoted to Ada (but I'd say you lose chances anyway, if only because of numbers).

So, again: Ada if self-contained development, Java if I need many libs, C/C++ if the project is already using it. In your particular example of Truecrypt... if for fun, Ada, but checking the crypto/disk needs first.

Ada is not foolproof though, and if you carelessly start to play with pointers you will lose sleep over the same kind of memory corruption errors (I must check Rust for precisely that reason).

Please do, it would be awesome if someone could debunk them and prove Ada to be superior after all their hot air :)

As for dev speed, the only place where you will slow down is designing thick bindings to C and C++ libs. Tedious isn't the word.

However, my personal dilemma would mostly be Ada vs Java; I avoid C/C++ if I can (there's too much of it anyway where I cannot choose).

Java is pretty bad, IMO, spaghetti code with all the patterns, really hard to follow.

Please do, it would be awesome if someone could debunk them and prove Ada to be superior after all their hot air :)

Hehe. Do you think though there is no substance there? From my superficial reads they get rid of a whole class of errors with the "ownership" idea. Although I don't really grasp the implications yet.

Java is pretty bad, IMO, spaghetti code with all the patterns, really hard to follow.

Certainly the lack of specifications are a step back from Ada. Interfaces mitigate it to some extent, although then one may get lost in the hierarchies; however the new shorthand notation for lambdas and reference functions for callbacks and single-method singletons goes a looong way in terms of local clarity and boilerplate reduction. I couldn't go back to Java 7. But then, that's also the merit of the tools, besides the language itself.

Anyway, I would consider Java instead of Ada mostly for reasons of libraries/community, rather than the language itself.

Hehe. Do you think though there is no substance there? From my superficial reads they get rid of a whole class of errors with the "ownership" idea. Although I don't really grasp the implications yet.

I have no idea, I've only really checked on the whole syntax of the language and it's not for me. But they do have this arrogance going on basically saying that everything should be rewritten in Rust and whenever you mention something they say "Rust has that" and then you find that it's in the library, not the language.

Anyway, I would consider Java instead of Ada mostly for reasons of libraries/community, rather than the language itself.

This is why we need more people working on libs for Ada, so people pick Ada rather than something else.

As for the tooling/libs on Java, yeah, they have loads, but Sun paid universities and company's millions for them to use the language. Plus, forcing everything into a class is coming back to bite them, this is why I think so many people are jumping on the FP bandwagon, there'll come a time when people think forcing everything into a function is bad.

code of conduct - report abuse