Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why isn’t the SDK written in C++?

This may be an unpopular question but the Nordic SDK seems to go to great length to perform what is effectively object-oriented programming while still avoiding c++. This leads to, among other things, an overly complex sdk rife with macro string concatenation and other evils. In our project we spent the first six months wrapping every part of the sdk into a coherent object model. The wrapping was painful but paid off dividends when we went to actually do the real work. 

Hopefully I don’t need to extol the virtues of c++ in embedded systems. Others have already done that for years: https://www.embedded.com/design/programming-languages-and-tools/4438660/Modern-C--in-embedded-systems---Part-1--Myth-and-Reality

Has Nordic considered this?  It would make your products much more attractive, at least to us. 

Parents
  • There are some counter arguments

    • C++ APIs can be hard or impossible  to use for non-standard languages, say PASCAL.
    • C++ ABI is not stable accross compiler versions, and some parts of the SDK is shipped in binary (NFC, uECC, SoftDevice)

    Also, the SDK is intended as a reference implementation for all the peripherials - to teach developers how to use them. Thus it needs to be relatively simple and easy to understand - and some hw devs may simply not understand C++ properly. Look at some of the questions in this forum...

    Much of the SDK is very closely tied to the hardware itsef. The C compiler is used as an "assembler with more macros" rather than a high level language.

  • I’m not sure to which parts of the API you’re referring. While there are a handful of bugs in the SDK that prevent direct consumption from C++, it is certainly possible as we are doing it in our project. 

    To be honest, some of what you’re saying seems to boil down to, learning new things is hard and people shouldn’t have to do hard stuff. But the reality is that the SDK is striving for an object oriented paradigm; it’s simply using an outdated language to do it. 

    Lastly, the idea that C++ compilers are not sufficiently standardized is completely untrue. Those sorts of myths are the reason many people refuse to make the switch and I don’t think perpetuating them is helpful. 

Reply
  • I’m not sure to which parts of the API you’re referring. While there are a handful of bugs in the SDK that prevent direct consumption from C++, it is certainly possible as we are doing it in our project. 

    To be honest, some of what you’re saying seems to boil down to, learning new things is hard and people shouldn’t have to do hard stuff. But the reality is that the SDK is striving for an object oriented paradigm; it’s simply using an outdated language to do it. 

    Lastly, the idea that C++ compilers are not sufficiently standardized is completely untrue. Those sorts of myths are the reason many people refuse to make the switch and I don’t think perpetuating them is helpful. 

Children
Related