Re: [PIC] Learning C
smplx <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 14 Nov 2024, Allen Mulvey wrote: > Yes, I think today, for some, it is a kind of "snob appeal" to use obscure > code but decades ago code optimization was mostly done by the coder not the > compiler. I think that is where some of it may have originated. Maybe but you should be aware that the precursor to C was interpretted so very tight code actually executed faster. I'm not sure when it went from interpreted to compiled. But even then the compiler would have been very simple, just converting source to assembler with ZERO optimisation. I belive that's why C has increment / decrement operators (i.e. ++ and --). To allow better code generation. > Today the > compiler can optimize much better than I can and most decent editor have > auto-format. This not only makes the code more readable but far easier to > debug. I frequently use "unnecessary" local variables knowing that the > compiler will take them away. It makes the code much easier to follow if I > need to come back to update the section. I totally agree with you and I too sometimes do the same. As you say if you need to come back to it you are only making life harder for yourself if you try to be clever - it doesn't work any better :-) > I actually discovered this by > accident a long time ago. After making some obscure code much more readable > the compiled size was unchanged. Personally, I think using obscure code is > foolish. I agree but I think a lot of people actually do that because they are copy/pasting code they don't understand and they are afraid to change it. Friendly Regards Sergio Masci