Safe, reliable, and secure software has one distinct characteristic: a lack of bugs. No programmer intentionally includes bugs in their programs, and most try to actively root them out. The challenge with many tools like C is that the language does not help prevent common errors. Tools like static analysis help, but few actually use them or have them available, even in this age of open-source software.
New languages like Rust try to address many of the issues programmers need to handle on a regular basis. For Rust, one primary aspect is memory management. Unfortunately, it is a relatively new language that is still changing, making it hard to choose for long-term, embedded applications.
There are other choices, however, and Ada is one of them. There are a lot of myths about Ada that are not true. Most programmers do not know about SPARK, which is built on Ada 2012; most will assume the myths about Ada apply even without looking closely at its features, such as Ada contracts that are actually a part of Ada 2012.
One company that actively supports Ada is Adacore. Its Make with Ada competition recently wrapped up. I was one of the judges, along with notables Jack Ganssle, Richard Nass, Stephane Carrez, and Adacore President Cyrille Comar. The competition targets Ada on embedded platforms like Arm’s Cortex-M. Yes, Ada runs on those little microcontrollers as well as cloud clusters. In fact, Ada initially targeted minicomputers that were on par with the latest microcontrollers when wirewrap systems were common. Ada even has its own multitasking support within the language, an important factor when one considers standardization among applications.
This year’s competition was very close and very interesting given the quality and quantity of entries. Last year, many competitors found the startup process to be challenging, and Adacore has addressed this by providing more support for microcontroller platforms with both its commercial and free open-source tools.
The first-place winner this year was Jonas Attertun from Sweden with an Ada motor control framework for developing a brushless DC motor controller (BLDC/PMSM). He used a custom, open-source board with an STM32F446 microprocessor. The algorithm used sensored field-oriented control. It included a logging feature to simplify development and allow users to visualize what is happening. For that, he took home an award of €5,000/$5,500.
The second-place winner was German Rivera from California for a Smartwatch project based on NXP’s Hexiwear IoT wearable development board with two NXP Kinetis microcontrollers. He was also last year’s second-place winner.
Third place went to Manuel Iglesias Abbatemarco from Ecuador for his Ada IoT Stack. Yes, Ada isn’t just for aircraft and military applications—it can also be used for the Internet of Things. This project added several components to the Ada Drivers Library to support an IoT Framework based on an existing lwIP (lightweight IP) implementation ported to the embedded STM32 Ethernet family of devices.
Ada has changed a lot since it first came out decades ago. It is a strongly typed language with support for features like generics and object-oriented programming. I have mentioned its multitasking support and contracts, but there is a lot more of note—including its module system that languages like C lack, necessitating runtime libraries (often non-standard). This standardization is actually a plus for Ada and SPARK when it comes to portability.
Check out the feedback from last year’s third-place winner, Shawn Nock from London, Ontario, who developed a Bluetooth Beacons “iBeacon” using Ada. He just started using Ada and did a great job even while learning a new programming language.
Also, check out "Assessing the Ada Language for Audio Applications" to find out how Dolby is looking at Ada for its audio support. This is a good overview of Ada and SPARK within the context of porting a C language implementation of the MPEG-2 Layer-2 decoder to Ada. One of the advantages of Ada is its fixed-point data type that is utilized in this example.
Check out Ada and SPARK if you really want to write safe, reliable, and secure software while concentrating on the application, rather than not accidentally adding bugs. They will still wind up in applications, but more likely in the algorithm rather than the implementation.