Re: which object orient language is most suitable for embedded programming?
- From: David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Nov 2006 08:54:53 +0100
Vladimir Vassilevsky wrote:
Donald wrote:
People may use C++ techniques but the most CPUs sold are 8-bit based, with limited ROM and RAM.
So C++ will not work on most 8-bitCPU based systems. But C++ techniques could be used in the design of such systems.
Nonsense.
The only reason for not using C++ for 8 bitters is that C++ compilers are not always available. However this is changing.
The claims about terrible inefficiency of C++ are the exaggerations. Also, the cases where the size/speed does matter are rear. If it really does matter, then most likely it signifies design level problems.
Two features of C++ can produce a lot of overhead in C++ programs, especially for small systems - exceptions and RTTI. If you can disable them in the compiler (and C++ compilers I have seen let you do that), then the C++ compiler should generate pretty much identical code for a C function compiled as either C or C++. In other words, no overhead. (Of course, if you make use of exceptions, then the overhead can be worth it.)
However, C++ makes it easier to accidentally generate very inefficient code - even easier than C does. C has a few pitfalls for the unwary embedded programmer, such as using "printf" and linking in a (relatively) huge floating point library. C++ has many more - for example, if you add a virtual destructor to your classes, because that's what you learned on your C++ course, your small classes are going to be an order of magnitude bigger and slower on a limited processor.
Writing efficient C++ code for small micros is certainly possible, and I've seen some very neat examples (like an 8-bit integer class for avrgcc that produced better code than an int8, because it avoided int promotions), but you need to know a lot about the compiler, the language, and the target to get efficient code.
Vladimir Vassilevsky.
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
- Follow-Ups:
- Re: which object orient language is most suitable for embedded programming?
- From: Steve at fivetrees
- Re: which object orient language is most suitable for embedded programming?
- From: Vladimir Vassilevsky
- Re: which object orient language is most suitable for embedded programming?
- References:
- which object orient language is most suitable for embedded programming?
- From: ***
- Re: which object orient language is most suitable for embedded programming?
- From: Tim Wescott
- Re: which object orient language is most suitable for embedded programming?
- From: Donald
- Re: which object orient language is most suitable for embedded programming?
- From: Vladimir Vassilevsky
- which object orient language is most suitable for embedded programming?
- Prev by Date: Re: External memory with ARM7 philips lpc2138
- Next by Date: why not access much than 8K of the sdram?
- Previous by thread: Re: which object orient language is most suitable for embedded programming?
- Next by thread: Re: which object orient language is most suitable for embedded programming?
- Index(es):