3 ms·
I would say most modern code is not the kind of code written with the absurd platform assumptions that old code used to do. There's not magic addresses you have
by xemdetia 5y ago
I would say most modern code is not the kind of code written with the absurd platform assumptions that old code used to do. There's not magic addresses you have to know to talk to hardware, there's no implicit memory segmentation/memory looping, and so on. Ever since most modern OSs try to prevent direct access or randomize address spaces and so on it just is hard to write code that is insane like the way we were.
So the question is are you contesting the POSIX defined behaviour over using more logical interfaces from the OS or the wild west where people were hacking around broken, platform-specific features and often broken or awkward system libraries or just the more modern case where people use the standard interface instead of a more performant one. In the latter case I agree I wish there was a more 'nice' way of doing more dynamic and efficient feature detection without making simple C programs crazy complex.
- Someone 5y agoI think it also helps that modern hardware is a lot less diverse. Most of the tools only run on systems that are little endian, where NULL is zero, chars are 8 bits, ints are two’s complement and silently wrap around, floats are 32 bits IEEE 754, etc, so code that erroneously assumes those to be true in theory isn’t portable, but in practice is. And newer C standards code may even unbreak such code. Ints already are two’s complement in the latest version of C++ and will be in the next version of C, for example.
- isomel 5y ago> code that erroneously assumes those to be true in theory isn’t portable, but in practice is. Be careful about undefined behaviour still. Even if your architecture have defined semantic, the compiler might still not assume them.
- dahfizz 5y ago> I would say most modern code is not the kind of code written with the absurd platform assumptions that old code used to do. That is a pretty bold claim. I would be surprised if any nontrivial "modern" program would be bug-free on a platform with nonzero NULL, non two's compliment ints, big endian an non IEEE floats. The assumptions we make about the platform just don't feel like assumptions anymore because every machine is the same nowadays.