Object Oriented Programming in Ada

It has been reported that blogger kqr argues Ada treats object‑oriented programming not as a single monolith but as a set of discrete features you can pick and choose. Encapsulation, reuse, inheritance, abstract interfaces, type extension, dynamic dispatch — Ada exposes them separately. The emotional hook is simple and human: “I never truly understood object‑oriented programming until I learned Ada.” It clicked for them. For readers tired of the one‑size‑fits‑all "class" mindset in languages like Java, that claim lands like a breath of fresh air.
Fine‑grained OOP: the Ada approach
Ada splits definition from implementation via package specification and body — think structured, compiler‑enforced header files — and it forces explicit choices. Want an interface? Declare type Engine is interface and make Run an abstract procedure. Want an extension that adds no fields? Ask for new Engine with null record; Ada makes you opt in to “nothing,” which often prevents subtle bugs. Primitive operations are just procedures, but the language has rules that make them methods of their type; overriding procedures are explicit. In short: Ada favors deliberate design over implicit defaults. A sledgehammer? Not here. A set of precision tools? Exactly.
Example translation and takeaways
kqr translated a small Java example — an Engine interface with TwoStroke and V8 implementations — into Ada to show the mechanics. The Java interface and classes map to an Ada package spec that declares the interface and child types, and a package body that implements Run for each type, printing the engine noises. The author admits the demo wasn’t wildly illuminating, but it does illustrate the point: Ada gives you fine‑grained control, which can make code easier to reason about and harder to accidentally misuse. Does that make Ada friendlier or fussier? Depends on whether you prefer control over convenience — and in safety‑critical and systems work, that control is increasingly in vogue.
Sources: entropicthoughts.com, Lobsters
Comments