Overridable Class Attributes in Ada 2012

One of the nicest features of the AdaCore website is the Ada Gem of the Week. Currently sitting at 117 gems, this place is a regular treasure-trove for Ada programming.

Today’s gem is written by Emmanuel Briot and it deals with some of the new Ada 2012 features, specifically in relation to object oriented Ada programming. it’s called Gem #117: Design Pattern: Overridable Class Attributes in Ada 2012.

Most object-oriented programming languages provide a facility for declaring variables that are shared by all objects of a given class. In C++, these are called “static members” (and use the “static” keyword), and similarly Python has the notion of “class attributes”.

Let’s consider an example where this is useful. For instance, let’s say we want to define the notion of a block of text that is generated by expanding a template (perhaps after we replace some parameters in that template, as can be done with AWS’s templates parser, for instance). Once we have computed those parameters, we might want to generate multiple outputs (for instance HTML and CSV). Only the template needs to change, not the computation of the parameters.

I can’t say I’m a huge expert on object oriented Ada programming, but this little snippet actually made me hungry for playing around with some of the new Ada 2012 features, such as expression functions, where you can do stuff like this:

pragma Ada_2012;
type Text_Block is tagged null record;
function Template (Self : Text_Block) return String
   is ("filename.txt");
function Render (Self : Text_Block) return String;

Instead of the old more clunky method:

type Text_Block is tagged null record;
function Template (Self : Text_Block) return String;
function Render (Self : Text_Block) return String;
function Template (Self : Text_Block) return String is
   pragma Unreferenced (Self);
   return "file_name.txt";
end Template;

Very nice indeed! The new Ada 2012 syntax allows for a much more simple and readable setup of the Text_Block type. But don’t take my word for it, go read the Gem instead. It is definitely worth it.

AdaCore and SofCheck Merge

This is pretty big news and it will mean even more bright Ada people gathered at AdaCore. Now some people may fear that, but I think AdaCore have shown themselves to be strong supporters of the Open Source community (though I dislike their release cycle), and I’m confident that merging with SofCheck will strengthen Ada:

“AdaCore and SofCheck have worked towards common goals for a very long time,” said Tucker Taft, SofCheck’s Chairman and Founder. “This merger is a natural next-step for both our companies: the whole SofCheck team is very excited to be joining up with AdaCore where together we can continue adding capabilities to the industry-leading CodePeer static analysis technology, while creating new offerings for customers building and certifying high-integrity software as they move into the multicore era.”

“Our complementary skills, shared history, and dedication to the software engineering principles supported by the Ada programming language have made this merger a positive, seamless experience for both companies,” said Robert Dewar, AdaCore President and CEO. “We particularly welcome Tucker’s addition to AdaCore’s existing team of experts, which will help us move forward with our joint goal of improving software engineering capabilities for developers of safe, secure, and highly-reliable software applications.”

Tucker Taft and Robert Dewar in the same company is bound to lead to good things. Both have contributed massively to Ada, and hopefully they’ll continue to do so for many years still.

If you’re in the mood for some more information there’s a nice little press release, or if you’re really feeling adventurous you can go check out Tucker Taft’s ParaSail language, which appears to be humming along quite nicely.

Should we put up with software that doesn’t work?

Robert Dewar from AdaCore begins his Should we put up with software that doesn’t work? article with a statement:

We are used to software that dismally fails. What is surprising is that we accept this as reasonable. It is time to stand up and say we are not going to put up with this anymore. There is no excuse for junk software.

I could not agree more. It’s scary that the software business as a whole have managed to convince the world that it’s OK to deliver products that fail to function as advertized, and it’s even more scary that users have accepted this as normal. It’s a troubling development that buyers of software can expect less quality from expensive software than from cheap goods from other industries. Companies that manufacture and sell toasters are more liable in the world of 2011, than companies that manufacture million dollar software.

If software development is to be taken serious as both a science and a profession deserving of the term “engineering”, then we need to change our ways. A consequence of this change might be that the current model of selling boxed software will have to end. The constant need for new versions and features push the limits of our ability to produce quality products. If instead software is sold on a subscription basis or as a service, then stability and polish becomes more important than going from version 3 to 4.

But obviously this all starts with the user. As long as the users silently accepts the current state of affairs, nothing is going to change.

But luckily we have guys like Dewar, who are at least trying, even though it does seem like a pretty small candle in a very dark and giant room. The article is very much worth reading, especially if you’re in any way interested in software, which I suspect you are, since you’re here.

Dynamic Plug-in Loading with Ada

If you want/need to learn how to make use of dynamic plug-ins, then look no further! In the excellent article Dynamic Plug-in Loading with Ada (PDF) authors Cyrille Comar and Pat Rogers, both of AdaCore fame, dive into the world of dynamic plug-ins, object oriented programming and a crude simulation of instruments on an automobile dashboard.

Maintenance of high-availability systems (e.g., servers) requires the ability to modify, enhance, or correct parts of the application without having to stop and re-link the entire system. This capability is relatively straight-forward with interpreted languages or virtual-machine based languages such as Java, in which new code is loaded upon demand. In languages typically
implemented with static executable images this capability can be offered though dynamically loaded/linked libraries (“DLLs”). However, in practice it is impractical to make full use of this
capability because the protocol for invoking subprograms in a DLL is very low-level and unsafe. In the case of Ada, global coherency requirements and elaboration ordering constraints add an
additional degree of complexity over less strict/safe languages.
Object-oriented programming makes this approach practical by using dynamic dispatching to invoke dynamically loaded functions with a more robust, high-level protocol. In an OO paradigm, a “plug-in” contains new classes that enrich the class set of the original application. Calls to subprograms in the shared library (plug-in) are done implicitly through dynamic dispatching which is much simpler, transparent to the programmer, type-safe, and more robust. This application note shows how a statically-typed, statically-built, object-oriented language such
as Ada can make full use of the notion of dynamic plug-ins á la Java without relying on a comparatively inefficient virtual machine. We build an extensible application and illustrate
adding new functionality at run-time, without first stopping execution, using plug-ins.

It’s a very informative read, with lots of source code coupled with well-written explanations. Definitely worth your time, if you’re interested in Ada, OO and dynamic modules/plug-ins.

If you don’t care for PDF’s, there’s a somewhat abbreviated version of the article available at Dr.Dobb’s.

High-integrity object-oriented programming with Ada

Written by Benjamin Brosgol from AdaCore, this article series digs deep into the bowels of Ada and its OOP features, specifically into high-integrity systems. It is a very interesting read, with lots of exact information. Clearly Benjamin is an experienced and skilled engineer.

It’s a three part article, of which two parts are currently available.

Part 1 of this three-part article reviews the basics of object-oriented programming and summarizes the challenges it presents for high-integrity programming. Part 2 will provide a primer on the Ada programming language, and Part 3 will detail the tools Ada offers to help developers meet the OOP challenges.

If you are in any way interested in Ada and OOP, then these articles can serve as a good place to start.

I will of course link to part 3 of the article series, as soon as it’s made available.

GNAT GPL 2011 is out!

And so is the 2011 versions of all the libre.adacore.com software, such as AWS, XML/Ada and GNATcoll.

GNAT GPL 2011 is, as you probably know, the GPL edition of the AdaCore Ada compiler. The package comes complete with compiler and the excellent Ada/C/C++ IDE GNAT Programming Studio.

Obviously there are a lot of changes and new stuff in the 2011 GNAT GPL package, but some of the most notable are:

  • Improved support for Ada 2012
  • More flexible and more efficient project manager tool
  • Support for unloading Ada plug-ins
  • Improved support for Ada constructs on the .NET platform
  • More detailed exception messages (-gnateE switch)
  • complete support for Lego MINDSTORMS hardware, including audio and I2C sensors

I’m especially interested in the new Ada 2012 features and in the -gnateE switch. I could do with some more information in my exceptions.

I haven’t tried any of the new stuff yet, as download speeds are currently abysmal. GNAT GPL is downloading at 18.8kb/s so it’ll be a while yet before I can get my hands on the shiny new stuff.

AdaCore @ YouTube

I’m on of those people who enjoy tech-talks on video, so when I found out that AdaCore have a channel @ YouTube, it made my day.

Yes, I’m that easy to please. :o)

It’s a fairly busy channel, with regular updates. Some of the subjects dealt with are:

And of course lots more. Be sure to check it out!

Programming with GtkAda

Creating programs with graphical user interfaces was not the primary concern when Ada was originally designed, but that doesn’t mean that it’s an impossible task today.

One of the options available is GtkAda, which is a binding to Gtk+.

Now, knowing that you can do graphical user interfaces in Ada is not the same as knowing how, and that is where today’s tutorial comes into the picture:

Programming with GtkAda.

This is a collection of resources and examples related to building a graphical user interface with GtkAda, or as it is said:

This page is for people who are beginners with GtkAda. It is a collection of resources, examples and helpful links. Gadget and Walker are tutorials which take the beginner programmer into the mysteries of widgets. They deal with the creation and use of a Graphical User Interface using buttons with icons and labels.

If you plan on trying your hand at GtkAda, then this is most certainly a good place to start.

Meet Some Of The AdaCore Experts

By chance I stumbled on a page at the AdaCore website, where some of their Ada experts talk a bit about what drew them to Ada in the first place. It is of course one big advertisement for AdaCore, but it’s a very interesting read nonetheless.

Meet the AdaCore experts.

I for one thought it was very nice to be able to put a face to the name Emmanuel Briot, because he is one of the lead developers on the GNATcoll package, which I just happen to use.