News for hackers. Stuff that matters.

theobserver

Re:C Books and C++ Books You Don't Want on Wednesday December 26, 2012 @05:50AM (#4968819)
Sorry to hear that. The problem with assert() at production code is that it crashes the program. IMNSHO, it's a medicine worse than the disease (is this why we get a "blue screen" on a popular OS?). Most, if not all tools should be lenient about errors - both user errors and system/environment errors - not just safety systems. There are very few cases that a tool should say "there is a problem, please contact the vendor" - and even then it is unreasonable to do it while crashing (maybe the user is willing to give up the last task but wants to start over with a different task). If you are not convinced, I am not able to explain it in any simpler and clearer way. Thanks for your time.
Re:C Books and C++ Books You Don't Want on Tuesday December 25, 2012 @08:06AM (#4965905)
"There's no table of contents." Really? Did you look at the top?
Re:C Books and C++ Books You Don't Want on Tuesday December 25, 2012 @07:57AM (#4965888)
I think you missed the point: I agree that using assert() is good for declaring invariants - but it is used only at debugging (as the quoted text says). If you don't turn assert() off at production (NDEBUG) you are in a deeper problem. The main thing should be that assert() does not replace if() or other conditionals (say for testing successful scanf()), and moreover, assert() should be used in a textbook when teaching debugging - not when teaching the basics of programming (likewise, only a very advanced student-driver is taught how to restart a stalled engine while in 60mph motion on the freeway - not a beginner one).