I have a friend who is a Pic compiler writer and when he wants to see whats the best possible code he will run it through the CCx compiler. There is nothing better for producing the tightest code.

C though as has been pointed out is not the best language for a PIC it's meant for PC's, so unless you are writing big code on say a 18 series I recon it gets in the way. I does though make you write proper code in that you have to cast the variables so you think hard about what type you need and maths can only have 3 arguments.

In the Picbasic world the only compiler that really tries hard to produce the tightest code and that's Proton

Take this code for example for 16F877

a var byte
b var byte
c var byte

if a > b then
a = c / 4
endif

Pbpro will compile it to 50 words in but in Proton it will do it in 13 words. That will match the CCxs compiler.

If you change the code to

gosub sub1
stop

sub1:
if a > b then
a = c / 4
endif
return

Pbpro takes 57 words, Proton takes 16 and I think CCxs will take about 14 or 15. as its clever enough to see that Sub is only used once and will just let it run into the routine and place the stop afterwards.

I doubt if I will ever use C as its so hard to read and while you can do any thing you want to in it you have to do it your self. The only thing I like is the code reusability in C not even Proton makes it as easy. But that's only for a short while as even that I'm going to crack with a new IDE plugin.

A number of C's have an optimiser pass again the only Basic compiler to have that is Proton.

I do agree with this though

- the best tool - is the tool you have on the desk
- the best software - is the software that you learned