
Modern C++ in embedded systems – Part 1: Myth and Reality - AndreyKarpov
http://www.embedded.com/design/programming-languages-and-tools/4438660/1/Modern-C--in-embedded-systems---Part-1--Myth-and-Reality
======
TickleSteve
Interesting. I was going to write a similar article myself, tho showing how
C++ can be more efficient for even 8 and 16 bit processors than even C.

The combination of templates, an optimising compiler that inlines code nicely
and avoiding virtual functions means you end up with extremely efficient code
while still allowing nice abstractions where necessary.

Part of the trick is to also avoid dynamic code as much as possible; it is
critical in embedded systems to avoid including any code that is wasted in a
single-application system. This means no dynamic-memory allocation, statically
allocate everything and use templates for drivers so addresses can be inlined
straight into the code allowing the compiler to remove any overhead. Doing
this means, startup time (and importantly, wake-up-from-deep-sleep time) is
minimised all the while allowing for nicely decoupled code through the use of
C++.

