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.