C or C++: Which Is Used In Firmware Development?

At Electronic Partners, we use C in the majority of the projects we’ve worked on with our clients, such as those listed above. Why is this? First and foremost, C remains the most common programming language, which is largely due to its smaller executable size and installation footprint. C is also generally easier to work with. That is, most embedded projects often don’t need – or benefit from – the features offered by the object-oriented coding of C++.

Unless specifically requested by our clients, we prefer to develop in C for the reasons outlined above. But this doesn’t mean that C++ isn’t still a worthwhile option in some edge cases, or for pre-existing projects where rewriting the code in C++ is deemed an unnecessary use of time. C++ offers a deeper, low-level control when compared to C, however this extra flexibility does come with tradeoffs, namely that the C++ executable tends to be larger, and the compiler adds extra overhead, which can lead to issues when developing for smaller, embedded electronic projects.

The prevailing attitude within portions of the development community is that C++ is only useful in a limited array of hardware scenarios, such as machines boasting larger reserves of memory than standard embedded systems. This line of thinking isn’t always correct, as C++ is used in hardware and firmware from the likes of Apple, as well as in NASA’s very own Mars Rover.

The common thread between these devices is that they all use a restricted subset of C++. So while it’s true that C++ itself may prove unwieldy when it comes to embedded design, by imposing restrictions and constraints during the development process, C++ remains a viable option in firmware development. And while its place may not be in embedded design, the likes of C++ and C# can instead be used to develop PC applications used in the testing of embedded projects.