A typical argument for removing claims from production code is performance. It makes no sense to me. Yes, disabling multiple statements from critical critical 5% or so of your code can be a useful optimization. However, for the remaining 95%, they probably have no measurable effect, and statements can only increase the likelihood that if your code has an error, it will be quickly and easily diagnosed.
I do most of my programming in D, which has an enforce() function that does basically what assert() does, except that it remains in the build versions. I usually use enforce() most of the time, and assert() only in a few places where enforce() will be too expensive.
Is there any other reason besides performance for removing claims from releases? If not, then why languages ββdo not allow standard statement behavior to always be executed even in release builds and provide a second function that is more complicated and difficult to remember, something like expensiveAssert() , which is removed from releases and recommends it to be used only in performance-critical ones parts of your code?
source share