this is a fascinating piece of advice - there is no argument against heavy use of assertions i have heard which isn't "oh but i'm lazy and don't want to do my job properly" and whilst that is e.g. the justification for python as a language in the first place that we don't want to spend time writing bytes, its not about convenience in this case but necessity. writing everything at the lowest level is not necessary, but writing stable code is. assertions help you do this, they will not become obsolete until e.g. static code analysis becomes good enough to replace it.
this comment is also scary from the C family of languages background:
"When using assert properly, this is a feature, but when assert is used inappropriately, it leads to code that is completely broken when running with the -O flag."
why don't people test their software by merely running it? esp in the config it will ship in.
> this comment is also scary from the C family of languages background:
> "When using assert properly, this is a feature, but when assert is > used inappropriately, it leads to code that is completely broken when running with the -O flag."
That's more or less how all compiled languages work - it's not a bug, nor is it scary. Developers want things their users don't, like assertion calls, debug symbols and additional type/bounds checking and whathave you; things that, while helpful to a developer, would only slow down the program by requiring greater amounts of CPU and ram to run. That's why these things are compiled out of "release" builds.
Yes, this can introduce very rare and subtle bugs, and not just from people making assertion calls with side effects -- but also from additional belt-and-braces checks placed by the compiler in the dev build.
i think you misunderstand me, what is scary is that the comment needs making at all.
"why don't people test their software by merely running it? esp in the config it will ship in."
i.e. why aren't you testing what you ship. i.e. with the -O flag on. the fact that build flags cause headaches like this is well understood from my history with languages using the C preprocessor - all C, C++ etc. programmers will have a good handle on this from necessity i think. it scares me to think that people are writing code but not understanding what it is going to do...