Consider expanding what you normally think of as “embedded”: I develop embedded C applications but our box has the same processing power as a gaming computer.
Most safety-critical applications are written in C or Ada.
Most safety-critical applications are written in C
This puzzles me — wasn’t safety one of the main reasons for developing alternatives to C and C++?
You’re thinking of things like type safety, garbage collection, etc.
I’m talking about safety in terms of people dying. Things like garbage collection are the opposite of life safety: what if your airplane decided it needed to free up memory ten seconds from touchdown so it ran the garbage collector? What if running the garbage collector caused a valve to respond 0.1 seconds late to a command, which caused a chain reaction resulting in a hydraulic line bursting and losing control of the rudder?
C can be safe because it does exactly what the programmer tells it to do, nothing more and nothing less. There’s no magic going on behind the scenes which could have complex interactions with other behind the scenes magic.
A common example is C++’s std::vector. This container expands as needed to accommodate as many elements as you need. But you have a limited amount of memory on the system, so you need to do static analysis to determine the maximum size of that vector. And you need to be sure that you have enough memory for that plus everything else in your system.
We’ll now you’ve eliminated a lot of the convenience of using std::vector: you might as well just allocate that max size to it and avoid all the overhead std::vector imposes by growing in size.
The other main advantage of std::vector is templates. If you were to use a template in safety critical code you’d need to prove that the code generated by the compiler is correct for every template. We’ll now you’re diving down into all this auto-generated machine code: it would be easier to just write that code yourself and avoid the complexity introduced my the compiler’s template generator.
So, if we’ve eliminated all the usefulness of std::vector, why use it at all?
Repeat that process for most features in most languages and voila! You’re back at C 🙂