Ada Watch: Choosing a programming language that supports reliability
Choosing a programming language is a complicated decision as it can greatly influence the expected reliability of a software system — especially in military applications. Almost any language can be used to develop any application, but a language’s original design benefits may not carry over when moving from one domain to another. The Ada language can help developers produce very reliable programs due to its strong typing and other inherent safe characteristics, which make programs more easily understandable and modifiable without side effects.
Today’s programming language landscape is very rich, but for critical embedded applications a few tend to be more frequently used than others. A partial list might comprise Ada, Assembly, C, C++, and Java (in alphabetical order). These languages (roughly and not exhaustively) were defined to support, respectively: reliable and maintainable systems, direct manipulation of hardware and devices, building of operating systems and similar software tools, adding the then-new object oriented programming (OOP) paradigm to the base C language, and support for highly portable applications. Each excels at developing applications that are in its domain or share characteristics with applications in that domain.
The Ada language can help produce programs that are very reliable due to its strong typing and other inherent safe characteristics. These same characteristics make programs more easily understandable and modifiable without side effects so that they are more maintainable. Assembly language cannot be beaten if an algorithm is required to directly manipulate a computer’s instructions or data. C is a relatively simple language where source instructions typically map to a set or collection of common computer instructions or data manipulations. The term “thinking man’s assembler” has been used to describe C to convey this concept. However it has the advantage over assembly in that it allows for manipulation of the computer using higher level concepts and thus allows writing more advanced applications. C++ uses C as its basis and most notably adds OOP support to this base. OOP allows problems to be broken down into smaller manageable ones and then built up creating solutions for the higher level problem being addressed, in a way that promotes sharing of both low and high level components. OOP can excel at software reuse in this general sense. The Java language was designed to promote portability as its primary goal. It is a pure OOP language encouraging inheritance and reuse of existing components, has a more strongly typed data model than C or C++, but strives to prevent direct hardware access/manipulation as is possible with C/C++.
Thus assembly is a great language for directly manipulating computer hardware. Ada is very good for developing large, long lived systems or systems where reliability is important. C is good for developing applications that only require a fairly low level of abstraction between the application and the computer. That is, the software developer performs the task of translating a domain solution into instructions that make this execute on the computer. C++ adds OOP concepts along with templates, name space management and other features that aid in software reuse and building large scale applications. Java is ideal where portability is the key design goal. As a modern programming language it also has more powerful typing and program packaging concepts than C or C++, so software developers do not have to directly translate a solution into something that manipulates the computer (in fact they can’t in many cases with Java).
Each of the above languages will excel when used in the application domain it was intended for. Each may not be as good a fit for other domains. The Ada language may be a bit verbose in its syntax for writing very small programs or for programs that have a limited lifetime. Readability and maintainability are less critical in these cases. C’s ability to map directly to a hardware solution is not an advantage as a software developer must write medium to large programs where this mental translation from problem solution to computer instructions is difficult to manage; programmers make mistakes. Since the language assumes that developers mean what they say (type), it will interpret many mistakes in the algorithm as simply being their intention and the errors will be integrated with the software undetected.
With C’s fairly simple language syntax, developers can write large amounts of source text quickly. This sometimes gives the misimpression that large amounts of correct software are being written. This is often not the case and a comparison of productivity between C and Ada may actually show that Ada developers are more productive in writing correct source code. The C++ language adds benefits to its C base, but carries forward many of the same detriments found in C. Java provides portability but often as a tradeoff between real-time performance characteristics making such programs difficult and thus less productive to write.
I am not saying one language is better than another. I am saying that a single language is not the best choice for all applications. If reliability is important then the Ada language is a good choice.