Editor’s note: This is an excerpt from an article by Jack Ganssle on embedded.com.
The latest version of the Ada programming language received the approval of the International Organization for Standardization in Dec. 2012. The Ada Resource Association and Ada-Europe said Ada 2012 brings enhancements in the area of contract-based programming. Among other features, Ada 2012 adds the ability to specify preconditions and postconditions for subprograms, and invariants for private (encapsulated) types.
Ada 2012 also includes enhancements to the containers library, additional expressiveness through features such as conditional expressions and more powerful iterators, and support for multicore platforms.
Here, Jack Ganssle proposes a discussion with the folks at AdaCore.
---------------------Are Ada's run-time libraries generally written in Ada? If not, why is that?
The only compiler I can speak about is GNAT. Yes, for GNAT, the run-time libraries are indeed written in Ada. In the case of GNAT, most of the compiler is also written in Ada. (The rest being the standard GCC technology, written in C.)In some circles Ada has long held a reputation of being bloated, in terms of size and performance of the generated code. I know there are some profiles, like Ravenscar, that can scale back the size quite a bit. How does the code generated by modern compilers compare to that from, say, C of C++ compilers?
With today's technology, there's no reason why code generated from Ada would be generally slower--or faster--than that of a program doing the same thing written in C or C++. A couple of interesting points are relevant here:
• The fundamental computation model of Ada is imperative, and most concepts of imperative programming are available with semantics that are very close to those of these other languages. There is no reason why those in Ada would be slower.
• In the case of GNAT, the code generator is the same, whether you compile for C, C++ or Ada and that's where the bulk of the optimizations are performed. As a result, for the same algorithms, the performance will be the same.
• One common mistake in comparing the performance of Ada with that of C is to compare Ada with checks enabled and C without checks. Indeed, if you assign a value to a numeric type in Ada, the compiler will generate a check verifying that the value is in range, which takes more time than just doing the assignment. However, we then have two programs that do different things so the difference in performance is reasonable. It's perfectly possible to produce the same performance in Ada by altering the semantics, in this case removing those checks.
• There are a number of cases where code generated by Ada is actually faster than C or C++ code because the language provides semantics that can be better optimized by the compiler than code that's written manually. Subtype checking is a good example of that.
• For run-time size, comparing Ada with C++, which offers the same level of capabilities (object orientation, exception, multi-threading, etc), is the most relevant. It shows a comparable run-time footprint. Indeed, for smaller systems, smaller Ada run-times exist: with GNAT, you can go all the way down to no run-time at all.
Continued on embedded.comAbout the author:
Jack G. Ganssle is a lecturer and consultant on embedded development issues. He conducts seminars on embedded systems and helps companies with their embedded challenges, and works as an expert witness on embedded issues. Contact him at firstname.lastname@example.org
. His website is www.ganssle.com
. See related links: High-integrity object-oriented programming with Ada
High-integrity object-oriented programming with Ada - Part 1
High-integrity object-oriented programming with Ada – Part 2
High-integrity object-oriented programming with Ada - Part 3
Ada 2012 language standard gets ISO approval----------------------
If you found this article to be of interest, visit Military/Aerospace Designline
where you will find the latest and greatest design, technology,
product, and news articles with regard to all aspects of military,
defense and aerospace. And, to register to our weekly newsletter, click here.