3 ms·
C, is high level language that happens to map really well to hardware. Much of UB is UB simply because it difficult to effectively detect when something goes in
by quelsolaar 3y ago
C, is high level language that happens to map really well to hardware. Much of UB is UB simply because it difficult to effectively detect when something goes in to a state of UB. Writing to a memory address can be done in one instruction, but figuring out if that address is legal to write to is a slow and complicated process. The C standard let an implementation ignore that problem, but it is also does not stopping the implementation from making sure the address is valid before writing to it. Almost no one tries to make such an implementation, because the users have decided they would rather have speed, but anyone can write a ISO compliant implementation without any UB if that's what they want.
- bandrami 3y agoIt maps well to hardware from the 1970s and 1980s. It has very little to do with modern hardware, and for that matter modern hardware does some somersaults to present an interface that C "expects".
- _rubs 3y agoWhat are the specific differences?
- throwaway17_17 3y agoThe easiest read on this topic is Chris Chisnall’s ‘C is not a Low Level Language’ article [1]. It is a good read in general and not all that long. It addresses vectors, out-of-order execution, pipelining, and plenty of other topics along the way. 1 - https://dl.acm.org/doi/10.1145/3212477.3212479 https://dl.acm.org/doi/10.1145/3212477.3212479
- quelsolaar 3y agoModern hardware is designed to map to C rather than the other way around. Turns out people want to buy hardware that can run existing software.