Exactly this. I've felt it while checking some C++ OSS projects, thinking "wow I am more Java than this, and I don't do Java". This prevented me directly jumping into C++ which would be the natural step coming from C (because in reality it's not the natural step)
tialaramex|1 year ago
In C it often (too often actually but that's a different rant) feels as though what you wrote just translates directly into what the machine does, no surprises, so then it seems intuitively to make sense that this delivers good performance. And it's not anywhere close to obvious in idiomatic C++ or Rust, where yeah, "more Java" in some sense.
One option is to trust it, it's the fastest option as it's no work but you may find you can't bring yourself to do that.
Another option is to satisfy yourself by measuring, time it, or measure how big it is, now and again when you find something that seems like it ought to be dramatically worse - is it really worse? Huh.
The final option, which is very time intensive, is to learn the depths of how this actually works. That probably means learning assembly language, and a bunch of things about how CPUs work, how memory works, etc. If you never did this for C, I'd suggest not starting now as it's a huge time sink and is often going to shake what you thought you knew. But it's an option if you aren't satisfied by the other options.
jb1991|1 year ago
Note that most people who use Compiler Explorer don't actually know assembly that well, but you don't need to know it to see what is happening at a basic level, which usually suffices.
However, it is not necessary to care so much about performance in most cases. The language is generally fast compared to other languages, even if you don't try to make it fast -- the compilers and the language spec usually have that outcome. But when you really want to squeeze out the most efficient code, Compiler Explorer is the way most people do it.