3 ms·
"Classic" C was actually simpler and safer than modern C. Before optimizers, C was a WYSIWYG language. Yes, you can shoot your foot (gets) but you know what's
by greenhouse_gas 10y ago
"Classic" C was actually simpler and safer than modern C.
Before optimizers, C was a WYSIWYG language. Yes, you can shoot your foot (gets) but you know what's happening where, and can manually check everything.
Modern C with language lawyering can "optimize out" your safety checks, leading to exploits.
- pcwalton 10y agoYet those optimization passes have been essential for keeping C alive. Optimizing C well depends on exploiting undefined behavior. And if not for optimizing compilers, I think C would have been replaced a long time ago. For example, when everything can legally alias everything else (as in the case of "classic" C), it's hard for a compiler to prove anything about the contents of memory. This prevents a lot of seemingly-obvious optimizations. The problem with C is that you need to violate many programmers' assumptions about how the language operates in order to make it fast. It's not a coincidence that a lot of C/C++ compiler developers have ended up moving on to other languages.
- pjmlp 10y ago> It's not a coincidence that a lot of C/C++ compiler developers have ended up moving on to other languages. Some examples are Chris Lattner, Doug Gregor or Cliff Click. Or as Chris Lattner puts it, he writes C and C++ so that we don't have to.