Embedding C or C++: Is that really the question? - Embedded.com

Embedding C or C++: Is that really the question?


In a recent blog, a new embedded systems developer asked for advice about when to use C and when to use C++. This question captures the dilemma that even the most experienced programmers face at some point.

The responses to his blog question in general suggest using the two in combination on an as needed basis, selectively using features that help you and ignoring the ones that give you problems.

While such an in-between solution may be appropriate in deeply embedded 8-, 16-, and 32-bit MCU designs, several trends may force developers to leap with both feet into the C++ camp. This is especially so if you are an embedded developer who is also looking to broaden his or her spectrum of professional opportunities, beyond just those control-oriented applications appropriate to traditional C programming.

For one thing, there are the many embedded consumer and network designs created by teams of developers with millions of lines of code that need the sophisticated object-oriented and reuse features of C++. And then there is the shift to the use  of C++ or a variant in multicore programming . Some recent articles on embedded.com on this topic include:

High-level parallel programming model simplifies multicore design
Transcoding video with parallel programming on multicore
Multicore technologies and software challenges

In addition, in system level SoC circuit design there is the increasing use of C++ extensions such as SystemC to mimic the parallel operations inherent in such gate level HDLs such as Verilog and VHDL. Recent articles on embedded.com on this topic include:

Using SystemC to build an SoC platform
Transitioning from C/C++ to SystemC
When C++ hits the hardware
High-level synthesis of SoC designs  

Finally, in a variety of industrial wireless M2M and sensor apps, MCUs will be interfacing to enterprise servers and networks, where C++, and not C, is the programming language of choice.

To help you assess which language to use in a particular design and/or broadened your knowledge of broader professional opportunities, a number of design articles are available on Embedded.com to will help you make informed decisions about C++, and once you have made the shift, they will help you learn more about this more complicated – and more powerful – extension to C.  A particular favorite of mine is “Dive in to C++ and survive .” Other articles I can recommend include:

Guidelines for writing efficient C++ code
Delivering the benefits of C++ encapsulation
A six step process for migrating embedded C into a C++ framework
Building portable systems in C++

I have also included some columns from Dan Saks , who has waged a decades-long struggle to bring C++ into the mainstream of embedded systems program. Some recent columns that I have found particularly informative include:

How I got here
Poor reasons for rejecting C++
Better even at the lowest levels

Good reading!! Let’s hear from you on line at Embedded.com or by contacting me directly with your ideas and responses. (EET/Embedded.com Editor Bernard Cole, , 928-525-9087 )

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.