Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Per Westermark
07/12/12 02:05
Read: 497 times
Sweden


 
#187912 - As far as '51 goes - C++ is still viable
Responding to: Erik Malund's previous message
No. pooled memory isn't irrelevant. And can be needed for even very small devices.

But next thing - the previous post only covers the things where C++ can result in slower or larger code.

It totally ignores the differences where C++ gives advantages at zero cost to the target hardware.

Namespaces (explicit, or use of classes - especially with static members and zero instanced object, or local variables inside blocks) are always good to have. We want locality of reference and as small global name pool as possible.

Type-safe linking is great - the symbol names involved in the linking process just gets augmented with the parameter types and potentially calling convention.

Polymorph functions and operator overloading can make code easier to modify.

Use of references can help in situations where a pointer may not be null. A function that takes a pointer can just as well get NULL as parameter. A function that takes a reference will have the compiler verify that the user has an object - or the user have to be explicitly stupid and play creative games with type casts.

Bundling data and functions into classes gives easier-to-reuse code. It's possible to have a template of a ring buffer and just instantiate it, specifying "uint8" as data type and 32 as number of elements. And another instance with 64 elements of type "alarm_t".

For some reason, people spend too much time trying to find disadvantages with C++ - but the examples found are features the developer don't need to use. And that will not be more efficient in C if the developer really do need similar functionality.

List of 16 messages in thread
TopicAuthorDate
Who the hell uses C++ in embedded systems...      Jez Smith      06/18/12 06:58      
   So?      Per Westermark      06/18/12 08:08      
   beware of (verbal) inflation.      Erik Malund      06/18/12 10:17      
   Not as many as some would think.      Neil Kurzman      06/18/12 11:43      
      2% don't know      Jez Smith      06/18/12 13:00      
         Same same      Per Westermark      06/18/12 13:46      
         Surveys      Andy Neil      06/18/12 14:26      
   Me!      Oliver Sedlacek      06/19/12 04:30      
      Using tools that only supports C?      Per Westermark      06/19/12 05:13      
         Tools and MISRA      Oliver Sedlacek      06/19/12 06:22      
   C++ "better than C" for embedded systems      Oliver Sedlacek      07/11/12 20:48      
      as far as the '51 goes      Erik Malund      07/12/12 01:16      
         As far as '51 goes - C++ is still viable      Per Westermark      07/12/12 02:05      
            class vs source      Andy Peters      07/12/12 03:51      
         I did say "smallish"      Oliver Sedlacek      07/12/12 08:11      
            Overkill?      Per Westermark      07/12/12 19:01      

Back to Subject List