3 ms·
C is designed to be capable of running of vastly different architectures, allowing the programmer to use that flexibility when it actually isn't needed, or is h
by dsfuoi 10y ago
C is designed to be capable of running of vastly different architectures, allowing the programmer to use that flexibility when it actually isn't needed, or is harmful.
I think the C coding mindset should be this: if an approach requires code that isn't unambiguously defined, change the approach. If this means more boring coding, to circumvent cute tricks, so be it. If you need that extra 5% speed, use assembly instead of bending C.
- astrobe_ 10y agoThe problem is that people often don't even know what is UB and what is not. People don't even always know what is portable and what isn't, to begin with. Some even seem to believe that "it's written in C, so it's portable".
- dsfuoi 10y agoI strongly agree. There is a serious lack of respect of the C rules even among those who teach and this is passed onto their students. It is really hard to convince them to change ways after that. A couple months ago, as a curiosity, I watched a few videos in a series on programming in C in Windows environment. The teacher was a serious programmer, but the first thing that went out the window was strict aliasing. After that assumptions of integer sizes and range started creeping in. It came apparent that the teacher knew C, but only superficially, signedness, integer promotions and usual arithmetic conversions were treated like a nuisance. If the code compiled and ran, it was good. Those videos were the first C programming experience for at least several hundred people.