For decades there has been a debate among embedded software engineers on whether or not they should be using C or C++. For the foremost part, software provided by microcontroller manufacturers is provided in C, and actually, 56% of embedded software is written in C consistent with the 2019 Embedded Market Survey. However, C++ has slowly been gaining popularity and approximately 23% of the latest embedded software projects are written in C++. With C approaching its 50th anniversary, it’s going to be time to start out transitioning from C to C++. Here are three reasons why developers should consider making the change.
Reason #1: Improved architectural implementation
The C programing language does provide developers with encapsulation and a few basic polymorphism capabilities through function pointers. However, C is basically a procedural language and doesn’t provide mechanisms like inheritance or composition without extra effort. this will make the general architectural design of the system less ideal, which may then affect how the software is going to be reused and maintained and even limit its flexibility.
C++ provides developers with the power to implement truly object-oriented design patterns, develop real abstractions, and implement design patterns that will not only be reused from one application to subsequent but also improve an architecture’s flexibility. this enables the software to be reused, which successively may result in faster development, shorter customization times for client applications among many other advantages.
Reason #2: C++ is an evolving modern language
In today’s complex and innovative development environment, developers needn’t just cutting-edge hardware solutions but also cutting-edge software and language solutions. this suggests that the languages wont to write software got to be up so far to supply developers the newest tools got to implement their systems. The last update to the C language was in 2018, which seems like it’s been updated recently. However, if you check out the quality, there have been no new features added and therefore the only changes were to repair issues from the previous release which was in 2011! Yes, it took seven years to place out a revised standard that fixed the problems from that last one!
Looking at C++, the quality s committee is committed to updating the standard every three years! subsequent revision is predicted this year, 2020, with the last version being released in 2017. Unlike with C, the new revisions aren’t just bug fixes, but instead, add new features and functionality to the language in order that it are often current and supply the tools necessary to compete with other languages like Python. The new standards even remove deprecated functionality like trigraphs.
Reason #3: C++ may be a richer language
Most of the embedded software I even have written for microcontrollers have used the C programing language up until maybe 3-4 years ago. C++ has always offered a richer feature set than C, but it seemed around that point that the compilers had reached some extent where the compiled code was equivalent or better. That was once I began to dive into C++ and find out how rich the language had become and the way far more there was on behalf of me to find out about the language.
C++ allows developers to require advantage of features such as:
- Templates – which allows code to be written independently of any specific type
- Dynamic polymorphism – allows an implementation to be assigned at run-time
- Exception handling – which catches errors (shocking for any C developer)
- Compile-time static if statements
- Virtual functions
These are just a couple of examples and there’s such a lot more! of these tools make life programming an embedded system easier.
C++ may be a modern and evolving language where C seems to be static and evolving much slower. In fact, C is becoming the proverbial dinosaur in an age when programming languages are rapidly evolving. As developers face ever-increasing complexity within their systems, they have a language that permits them to be flexible and maximize reuse. Many complaints from the “old days” just not apply to C++ especially given how efficient C++ compilers became. If there was ever a time to start out transitioning to C++, this might alright be it.
Over subsequent several articles, we’ll look closer at C++ and the way developers can leverage it to style and build drivers for microcontrollers.
click here to download c++