Pointers Are More Abstract Than You Might Expect in C
This scratches the surface of why I hope C slowly fades away as the default low-level language. C sounds simple when you look through K&amp;R C. C lets you feel like you understand the stack, ALU and memory. A pointer is just an integer and I can manipulate it like an integer.<p>But the reality is filled with a staggering number of weird special cases that exist because memory doesn&#x27;t work like a simple flat address space; or the compiler needs to optimise field layouts, loops, functions, allocations, register assignments and local variables; or your CPU doesn&#x27;t use the lower 4 bits or upper 24 bits when addressing.<p>C has no way to shield common language constructs from these problems. So everything in the language is a little bit compromised. Program in C for long enough and you&#x27;ll hit a lot of special special cases – usually in the worst way: runtime misbehavior. Type punning corruption, pointers with equal bit representations that are not equal, values that change mysteriously between lines of code, field offsets that are different at debug and release time.<p>When using fundamental language constructs, we shouldn&#x27;t need to worry about these ugly special cases – but C is built around these ideas. The need to specify memory layouts, direct memory access and other low level access should be gated by barriers that ensure the language&#x27;s representation and the machine representation don&#x27;t tread on each other&#x27;s toes.<p>Rust has a long way to go but is so much more robust at runtime. I think there&#x27;s room for other languages to occupy a similar space but they&#x27;re need to focus on no-std-lib no-runtime operation (not always the sexiest target).