A new Embedded Ada book - Embedded.com

A new Embedded Ada book


Building Parallel, Embedded, and Real-Time Applications with Ada,” by John McCormick, Frank Singhoff and Jerome Hugues is a new book on Ada that's specifically meant for firmware developers.

This book does teach the Ada language, to a degree. But Ada newbies will find some of it baffling. The prose will clearly explain a code snippet but still leave the uninitiated puzzled. For instance, when this line is first used:

with Ada.TextIO; use Ada.TextIO ;

… the first portion is well-explained, but one is left wondering about meaning of the apparent duplication of Ada.TextIO.

The authors recommend using one of a number of other books for an introduction to the language, and they give a number of specific suggestions. Also suggested is the Ada Reference Manual (ARM), which is truly complete. And enormous (947 pages). And not organized for the novice. I find the ARM more accessible than the C standard, but it's not a fun beach read. Actually, it's not much fun at all.

But Chapter 2 of their book does contain a good high-level introduction to the language, and the section on types is something every non-Ada programmer should read.

Many of us grew up on assembly language and C, both of which have weak-to-nonexistent typing. If you've vaguely heard about Ada's strong types you probably don't really understand just how compelling this feature is.

One example is fixed-point, a notion that's commonly used in DSP applications. On most processors fixed point's big advantage is that it's much faster than floating point. But in Ada fixed point has been greatly extended. Want to do financial math? Floats are out due to rounding problems. Use Ada's fixed point and just specify increments of 0.01 (i.e., one cent) between legal numeric representations. Ada will insure numbers never wind up as a fraction of a cent.

About a quarter of the way into the book the subject matter moves from Ada in general to using Ada in embedded, real-time systems, which seems to get little coverage elsewhere even though the language is probably used more in the embedded world than anywhere else. Strong typing can make handling bits and memory mapped I/O a hassle, but the book addresses this concern and the solutions (“solutions” is perhaps the wrong word as the language has resources to deal with these low-level issues) are frankly beautiful.

I've always like David Simon's “An Embedded Software Primer,” for its great coverage of real-time issues. “Building Parallel, Embedded, and Real-Time Applications with Ada” is better at the same topics, though is a more demanding read. The two chapters on communications and synchronization are brilliant.

Chapter 6 covers distributed systems, one of Ada's strengths. The couple of other Ada books I have don't mention distributed systems at all, yet computing has been taken over by networks of computers and many-core processors. For instance, Ada provides pragmas and other resources to control activities distributed among various processors either synchronously or asynchronously.

The book does a good job of showing how CORBA can enhance some of the ambiguity and unspecified mechanisms in Ada's Distributed Systems Annex (an extension to the Ada standard). This is not simple stuff; the book is excellent at getting the ideas across but expect to be challenged while digging through the example code.

Chapter 7 is “Real-time systems and scheduling concepts.” It's a must-read for anyone building real-time systems in any language. The authors cover rate-monotonic and earliest-deadline-first scheduling better than any other resource I've read.

They show how one can use a little math to figure worst case response time and other factors. Ada is not mentioned. But later chapters show how to use Ada with multitasking. Also somewhat unusual in Ada tomes, the book does cover the Ravenscar profile. Ravenscar disables some Ada features to reduce some of the overhead, and to make static analysis of a program's real-time behavior possible.

As most people know, Ada has its own multitasking model. But some of this is specified by the standard as optional, and so the book addresses using POSIX as an alternative.

The book is very well-written, though sometimes a bit academic. The use of language does tend towards precision at the occasional cost of ease-of-reading. Every chapter ends with a bulleted summary, which is excellent, and a set of exercises. I don't find that the latter adds anything as no solutions are given. In a classroom environment they would make sense.

A lot of us get set in our ways. Even if you never plan to use Ada it makes sense to stretch the neurons and explore other languages, other approaches to solving problems. Heck, a friend in Brazil gave me a book about the Lua language which was quite interesting, though I've never written a single line of Lua and probably never will. “Building Parallel, Embedded, and Real-Time Applications with Ada” is one of those volumes that makes you think, especially about the hard problems (like real-time, multitasking and multicore) facing the firmware world today. I recommend it.

Have you explored alternatives to C/C++? What do you think of them?

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. Contact him at . His website is .

9 thoughts on “A new Embedded Ada book

  1. I'm a bit two-mindend about Ada. In my day job i use mainly C, sometimes a bit of C++. At home, every now and then, i do/try some side projects in Ada, because there is just something about it. Those are mostly just proof of concept things, or really pure

    Log in to Reply
  2. Would things like Linux, OpenCV/OpenCL, you name it, have happened at all? Would we even have GUIs, Internet, smart phones and whatnot? I'm honestly skeptical. There's and old saying in europe: “If you want a commercial project to fail, let an engineer man

    Log in to Reply
  3. And don't get me started with readability, i know someone who codes Ada in his day job, and yes, there is unreadable (in terms of not understandable) Ada code out there (think subtypes hell aka Bob's integer).
    Ada is a bit like Esperanto (just google it)

    Log in to Reply
  4. (1) I hope you are not implying that using a language such as Ada would somehow stifle innovation, creativity, and new tech. That would be completely ridiculous.

    (2) You are right that getting started on something in C or even C++ is quite easy since ther

    Log in to Reply
  5. To (1): You're right, this is not what i meant. But what i meant though, is that the whole Ada way (i.e. the language and its associated processes) makes “playing around” harder and more expensive. Again, small is how most great things start, and the C uni

    Log in to Reply
  6. Oh, and before i forget it. My comments were not meant as a rant. Mr. Ganssle asked (indirectly) if Ada is an alternative to C or C++. And objectively looking at it, and comparing all the pros and cons, it's not (IMHO).

    Log in to Reply
  7. Yes, you do make some valid points which may mean Ada is not an option in some cases. With regard to bindings, perhaps you can consider making a binding to something you needed and make it available. The more individuals that do, the better the situation c

    Log in to Reply
  8. Although you wouldn't tell it from my comments, yes, in my spare time i'm working on a couple of bindings ;-). But they're not ready for prime time.

    P.S.: I have only access to the GPL Ada compiler from AdaCore. You seem to be a commercial user. Would/cou

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.