3 reasons to transition from C to C++

For decades, there has been a debate among embedded software engineers whether they should use C or C++. According to the 2020 Embedded Market Survey, in most cases microcontroller manufacturers provide software in C, and in fact, 56% of embedded software is written in C. However, C++ is gaining popularity, with about 23% of new embedded software projects written in C++. With C approaching its 50th anniversary, it might be time to start converting from C to C++. Here are three reasons why developers should consider making changes.

Reason 1: Improved architecture implementation

The C programming language does provide developers with encapsulation and some basic polymorphism capabilities through function pointers. However, C is indeed a procedural language, and doesn't offer mechanisms like inheritance or composition without extra effort. This can make the overall architectural design of the system less than optimal, affecting how the software is reused and maintained, and even limiting its flexibility.

C++ provides developers with the ability to implement true object-oriented design patterns, to develop true abstractions, and to implement design patterns that are not only reusable within an application, but also allow for architectural flexibility. This allows software to be reused, which in turn can lead to faster product development, shorter customization times for customer applications, and many other advantages.

Reason 2: C++ is a modern language that is constantly evolving

In today's complex and innovative development environment, developers require not only cutting-edge hardware solutions, but also cutting-edge software and language solutions. This means that the languages ​​used to write software must be up-to-date in order to provide developers with the latest tools needed to implement their systems. The C language was last updated in 2018, so it sounds like it has been updated recently. However, if you look at the standard, no new features are added, the only changes are to fix issues from the pre-2011 releases! Yes, it took seven years to develop a revised standard to fix the problems in the last standard!

Looking at C++, the standards committee is committed to updating the standard every three years! The next revision is expected to be published this year in 2020, with the latest version due in 2017. Unlike the C language, new revisions are not just bug fixes, but add new features and functionality to the language, allowing it to be up to date and provide the tools necessary to compete with other languages ​​such as Python. The new standard even removes deprecated features such as trigrams.

Reason 3: C++ is a richer language

Most of the embedded software I've written for microcontrollers was in the C programming language until 3-4 years ago. C++ always provided a richer feature set than C, but around that time compilers had reached a point where the compiled code was equivalent or better. That's when I started learning C++, discovering how rich the language has become, and allowing me to learn more about the language.

C++ allows developers to take advantage of the following features:

Templates – allow code to be written independently of any specific type

Dynamic polymorphism – allows implementations to be assigned at runtime

Exception handling – catching errors (a shock to any C developer)

Compile-time static if statement

virtual function

These are just a few examples, there are many more! All these tools make programming embedded systems easier.

in conclusion

C++ is a modern and evolving language where C seems to be static and slowly evolving. In fact, in an era of rapidly evolving programming languages, C is becoming the proverbial dinosaur. As developers face increasing complexity within their systems, they need a language that allows for flexibility and maximizes reuse. Many complaints from the past no longer apply to C++, especially given how efficient C++ compilers have become. If ever there was a time to start transitioning to C++, it's likely.

There are really a lot of things to learn about the embedded Internet of Things. Don’t learn the wrong route and content, which will cause your salary to go up!

I would like to share with you a data package, which is almost 150 gigabytes. The learning content, interviews, and projects are relatively new and comprehensive! (Click to find an assistant to receive it)

Guess you like

Origin blog.csdn.net/m0_70911440/article/details/132574983