3 ms·
>>Not really, with compilers as sophisticated as they are and the spec as liberal with undefined behavior as it is. The C virtual machine that the spec defines
by bluecalm 11y ago
>>Not really, with compilers as sophisticated as they are and the spec as liberal with undefined behavior as it is. The C virtual machine that the spec defines is every bit as complex as any other virtual machine.
Having some undefined behavior in your code is just a bug, it has nothing to do with being complicated or compiling to machine code.
It's not nearly as complex, in fact there are many people who understand quite well what the code compiles to. You can read the assembly as well and understand it for big parts of the code (oh, it compiled it to that, vectorized this but didn't vectorized that etc.).
Try guessing what Java compiles to. It's not even close to the same level of complexity.
>>I totally agree. In fact, I wouldn't use C even for projects where a GC isn't suitable, just because we have alternatives
The only serious alternative as of today is C++. Rust is a new untested language which no one wrote anything quite serious in yet and which offers a lot of trade-offs in exchange for being safer, everything else is slow as hell.
- pcwalton 11y ago> Having some undefined behavior in your code is just a bug, it has nothing to do with being complicated or compiling to machine code. In theory, yes. In practice, all C/C++ programs have undefined behavior in them, so you have to understand what compilers do to really understand your code. > It's not nearly as complex, in fact there are many people who understand quite well what the code compiles to. Not true in my experience. The only people who really understand it are, by and large, compiler developers. There are very few compiler developers. > Try guessing what Java compiles to. I know what Java compiles to more or less as well as I know what C++ compiles to. The only real difference is in GC (which is quite simple--inline a nursery bump and fall back to a malloc-like slow path if it fails) and ICs, which are a lot less complicated than things like alias-analysis-sensitive load forwarding.
- fanf2 11y agoRe. undefined behaviour, this fairly definitive paper agrees that it has gone too far: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1637.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1637.pdf