3 ms·
I had no idea that such things are possible in C. The things about I've read recently (the "friendly" C suggestion) and this seem like violations of the spirit
by bakhy 12y ago
I had no idea that such things are possible in C. The things about I've read recently (the "friendly" C suggestion) and this seem like violations of the spirit of the language. And for what, really? The language looses its signature predictability, which to me seemed like a great feature of C.
If you write crappy code and expect the compiler to fix it for you, you should maybe consider another language. I can only imagine how hard it is to write reliable system software in a language that does these things.
- pjmlp 12y agoActually back in the old K&R days it was much much worse, as no real standard was in place, compilers were just kind of compatible with endless little surprises. Specially fun when trying at home your UNIX homework and vice-versa.
- pjc50 12y agoOther way round: the C language after optimisation is unpredictable, which makes it hard to write secure system software. You don't expect to write sound-looking code and have it broken for you by the optimiser.
- PhasmaFelis 12y ago> If you write crappy code and expect the compiler to fix it for you, you should maybe consider another language. This seems rather to be a case of writing good code and having the compiler break it for you.
- bakhy 12y agoYes it is. You misunderstood my point, which was about the purpose of existence for such optimizations - they are meant to improve code, which presumably needs improvement. But if your code needs improvement, then why not go for a higher level language? BTW, I gave you an upvote by accident :D
- clarry 12y agoThey are meant to make the code run faster. If your code needs optimization, going for higher level languages is seldom a good idea. You could try do low level optimizations in your C or assembly, but for most programs this will eventually backfire. So letting the compiler do its job is actually a good thing.