4 ms·
As a full-time C++ developer, my only gripe with features like these is that they require nontrivial compiler optimizations in order to produce the equivalent "
by Asooka 8y ago
As a full-time C++ developer, my only gripe with features like these is that they require nontrivial compiler optimizations in order to produce the equivalent "old-style" high-performance code. That leads to two issues for me:
1. Longer compilation times
2. Your program may be too slow in debug mode for you to meaningfully debug it
We're kind of at a crossing point where I would love it if I could have a compiler that "de-sugars" these expressions into optimized C code, i.e. removes the lambdas, adds local variables, etc. and then compiles with no or minimal optimizations for debug mode. I really love gcc's -Og mode, which should do something very close to that, but I still have to read the assembly code to get a full picture of what's happening. I feel like we could do a little bit better.
Edit: And if you're wondering why I care that much about performance, it's because there is really no reason to use C++ today other than to write high-performance software. There are other languages that can get bare-metal performance and I don't want to insult anyone using Fortran, Ada, etc. plus I'm keeping a close eye on Rust, but the combined tooling that exists for C++ still makes it a better, more productive alternative as far as I can judge. The other reason to use C++ would be to interface with a C++ system, in which case it might be easier to just write everything in C++ and skip the translation layer pain, but you might not care that much about performance in that case.
- jlebar 8y agoAs a C++ compiler developer I don't think these features are what's causing long compilation times. Most of them don't even require any changes to llvm. AFAIK ranges doesn't, and the changes necessary for coroutines are simpler than you may think. Next time you have a program that takes a while to compile, try profiling clang with perf! It's super interesting.