That is a big question that deserves a big answer beyond the scope of Hacker News threads. But a few points taken at random:
- The handle-body idiom loosens physical coupling but adds immense overhead to both time and space. For many applications in C++'s domain this is simply unacceptable, full stop. Applying the idiom ubiquitously would mean throwing out most of C and C++'s advantages for programmers in my kind of work.
- For real-time applications (soft or hard), it is important that the performance delta between debug and release builds is kept to a minimum, so you can use effective tools to debug a reasonable facsimile of the application in its final shipping form. This has numerous corollaries. For example, if member function definitions are generally put in .cpp files rather than header files to reduce physical coupling, then you get no cross-module inlining except when expensive, debugging unfriendly and incremental rebuilding unfriendly optimizations like link-time code generation are enabled. In principle, C has the same problem. But in practice, C++ programmers tend to use lots of small function definitions that each do a small amount of work and then defer to other functions. That style of coding depends on aggressive inlining for good performance; it's common to see a much, much larger performance gap between debug and release mode performance with C++ code bases than with C++ code bases for video games (which is what I know best).
Comments
Could you elaborate more on what trade-offs you see? Have you hit specific problems within your own code base?
That is a big question that deserves a big answer beyond the scope of Hacker News threads. But a few points taken at random:
- The handle-body idiom loosens physical coupling but adds immense overhead to both time and space. For many applications in C++'s domain this is simply unacceptable, full stop. Applying the idiom ubiquitously would mean throwing out most of C and C++'s advantages for programmers in my kind of work.
- For real-time applications (soft or hard), it is important that the performance delta between debug and release builds is kept to a minimum, so you can use effective tools to debug a reasonable facsimile of the application in its final shipping form. This has numerous corollaries. For example, if member function definitions are generally put in .cpp files rather than header files to reduce physical coupling, then you get no cross-module inlining except when expensive, debugging unfriendly and incremental rebuilding unfriendly optimizations like link-time code generation are enabled. In principle, C has the same problem. But in practice, C++ programmers tend to use lots of small function definitions that each do a small amount of work and then defer to other functions. That style of coding depends on aggressive inlining for good performance; it's common to see a much, much larger performance gap between debug and release mode performance with C++ code bases than with C++ code bases for video games (which is what I know best).