I'm just starting to read the literature related to embedded programming and I was wondering is there any C++ compiler for PIC worth looking at. I mean I was educated as a C++ programmer for PC and I got comfortable using objects. I'm getting very aware of the fact that in embedded programming I have much less memory space available and I have to look out for many details that were automated using various classes on PC.
So my question is are there any worthy C++ compilers for PIC and do I really need one?
It all depends on what you want to do with your microcontroller. Personally I will never dare to use c++ in any of my projects. Here are the reasons to avoid c++ ...
1) It makes code too much slow. This is of supreme importance for any software. It's lost art in today's "faster micro will take care of sluggish code". Most embedded systems have hard time-lines to achieve and every single cycle has to be utilized.
2) Increases code(ROM) size very rapidally.
3) Uses/asks too much RAM.
4) Does many things behind my back which may be needed by (careless
) PC programmer, but not in commercial world of embedded systems. Your system must function correctly with least or no human intervention. Even in case of fault, must do everything as gracefully as possible. So you must write the code & debug it with utmost care.
5) Embedded systems rarely have same requirements & configuration. Reusing code by means of classes, inheritance simply simply bloats the code. Your final code will carry unnecessay baggage which means you might need a micro with bigger memory or you have very small empty space which makes enhancements/addition of new features very difficult.
List can go on & on...
If you want to check how c++ affects your code, use AVR & IAR's EWAVR compiler which supports EC++. Write your code first in C then in C++. Just see the results. That will tell you why c++ haven't made it big in embedded world. This is true even for higher end processors like ARM.
I might add that I prefer assembly over C (even for PC programming). Though it takes more time to write & maintain(if written by someone else or badly commented), end result always makes you proud.
Just my opnion