In this new series, my aim is to convey the diversity and beauty of programming languages to people who are perhaps less enthusiastic about them than me, before they all go extinct. For some reason, I thought this would be fun to do using a pot plant metaphor. I’m sure I’ll come to regret this decision, but let’s run with it for now.
I’m going to start off with Ada, a language I was forced to learn as a student. At the time I didn’t appreciate it in its full glory, so this is perhaps an opportunity to make reparations. Handily, it’s also near the start of the alphabet.
Genus: A multi-paradigm, statically-typed language that supports both imperative and object-oriented styles of programming. If that sounds like gobbledy-gook to you, don’t worry — it just means that, in most respects, Ada is pretty run-of-the-mill, and wouldn’t look out of place besides C++, C# and Java on your window ledge (yes, don’t forget the pot plant metaphors!)
Ancestry: In many ways the last of the Pascal line, a family of languages that fought for light alongside C, C++ etc. back in the 90s, but strangely went out of fashion soon after.
Appearance: Here’s a program that produces the lyrics of the well-known1 song 99 pot plants on the shelf, according to Google’s Gemini LLM:
with Ada.Text_IO; use Ada.Text_IO;
procedure Pots_on_the_Shelf is
Number_of_Pots : Integer range 0 .. 99;
begin
for Number_of_Pots in reverse 0 .. 99 loop
-- Print the first line
Put_Line(Integer'Image(Number_of_Pots) & " plant pots on the shelf,");
Put_Line(Integer'Image(Number_of_Pots) & " plant pots on the shelf.");
if Number_of_Pots > 1 then
-- Print the middle line
Put_Line("Take one down, fill it with soil,");
else
-- Print the alternative middle line for 1 pot
Put_Line("Go to the store and buy some more,");
end if;
-- Print the last line
Put_Line(Integer'Image(Number_of_Pots - 1) & " plant pots on the shelf.");
New_Line;
end loop;
end Pots_on_the_Shelf;
begin
Pots_on_the_Shelf;
end;
If you’re curious, the output will look something like this:
99 plant pots on the shelf, 99 plant pots on the shelf.
Take one down, fill it with soil, 98 plant pots on the shelf.
< the same text with increasingly smaller numbers >
1 plant pots on the shelf, 1 plant pots on the shelf.
Go to the store and buy some more, 0 plant pots on the shelf.
The begin and ends in the code are a strong clue that this language is from the Pascal family. However, the interesting bit is the variable declaration at the top:
Number_of_Pots : Integer range 0 .. 99;
Ada is used in safety-critical systems, and is all about limiting the ability of programmers to make mistakes. This is most apparent in its strong type system. I talked about the importance of types in my post Reverting to Types, but Ada takes this further, placing tight guarantees about what values a particular variable can hold. You can see this in the program: the variable containing the number of pots can only hold values between 0 and 99, and Ada will soon correct you if you attempt to go outside this range. This means that you can’t accidentally start generating “-1 plant pots on the shelf” etc. — something that’s surprisingly easy to do in many languages.
Pests: What’s important for safety-critical systems can be pretty annoying to someone who’s just trying to scrape some code together for their assignment. As I discovered the hard way back in my student days, if you have a variable with a type “Integer range 1 .. 10” and another with a type “Integer range 5 .. 15”, you can’t copy a value from one of these variables to the other, even if it happens to be an integer within the overlapping range of “5 .. 10”. In retrospect, I realise this is to prevent any possibility of invalid values leaking between variables, but that’s little comfort to a sleep-deprived teenager. However, this forced me to think very carefully about what values a particular variable could hold during the run of a program — and this really is the main point, to make you think about the possible behaviours of your program, and use the type system to constrain it so that nothing untoward will ever happen.
Flowering period: Ada was released in 1980 and still remains the main language for safety-critical development, so it’s used for pretty much anything you can’t risk breaking down unexpectedly, such as planes, missiles, spacecraft and financial systems. This includes most Boeing and Airbus commercial airliners, jet fighters such as the F-16 and the Eurofighter Typhoon, the International Space Station, and much of the world’s air traffic control systems. So, no sign of it withering in its pot.
And that, in a pot plant, is Ada. At this point, you may be thinking “why is this relevant to me?” Well, dependability of software has always been a big issue, but nowadays, with people using LLMs to generate code, it’s become an even bigger issue. There’s lots of code out there, potentially running in production environments, that wasn’t written by a human programmer. In many cases, the programmer will only have a nebulous idea of how it works. This introduces some big risks, and these risks can be amplified or mitigated by the choice of programming language.
For example, code written in a language like Python — with no requirement to use types, and no type enforcement even if you do — is intrinsically harder to understand, yet at the same time has fewer constraints on what it can do. This makes using LLM-generated code written in languages like Python particularly risky.
If instead we were to use a strongly-typed language like Ada, then the presence of strict types would make the code more readable, but also potentially more reliable, since the types would constrain the behaviour of the program. They might even make it harder for LLMs to hallucinate non-sensical code.
In practice, it seems unlikely that people will go out and learn Ada just so that they can make their use of code-generating LLMs less risky. However, it’s still important to be aware of why types are important, and why we might want more of them in the programming languages we use. For more on this, see my previous posts Reverting to Types, Python, Destroyer of Worlds? and LLMs and the future of programming languages.
Okay, a bit of artistic licence here, but Gemini was good enough to play along with my adulteration of the lyrics of the better known 99 bottles of beer on the wall. Generating the lyrics of this song is a classic problem in introductory programming courses.
I'd say Pascal is part of the Algol family; something of a late bloomer that was designed primarily for teaching purposes. I fondly recall having to write all my own I/O routines (procedures) for it when I chose to write my PhD code in it 😄