Better HN
topnewbestaskshowjobs
Log inSign up

theobserver

6 karma · joined Dec 25, 2012 (13y ago) · 3 submissions

Submissions

comment 13y ago · link · parent

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.

comment 13y ago · link · parent

"There's no table of contents." Really? Did you look at the top?

comment 13y ago · link · parent

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).