4 ms·
Depends on your goals for production. The code above indicates a bug. In some domains it really is preferable to crash with righteous fury rather than to contin
by UncleMeat 3y ago
Depends on your goals for production. The code above indicates a bug. In some domains it really is preferable to crash with righteous fury rather than to continue executing with broken invariants and doing who knows what.
The assertion didn't cause you to have limited test coverage that let you edit the branch condition without detecting that it introduced a bug in the false branch.
Yes, if you've got a language that supports compile time checking of complex invariants then that's awesome! But few languages support this today.
- kccqzy 3y agoThe problem with crashing is that it is almost always a bad idea. You almost always want a limited scope crash that affects whatever currently is being processed. Imagine that in some languages an assertion raises an AssertionError exception which is caught by some faraway handler that causes the server the respond with a 500 error. That's strictly better than crashing. I also used to think it might be preferable to crash in some domains. With stories like https://news.ycombinator.com/item?id=37461695 https://news.ycombinator.com/item?id=37461695 it makes me think perhaps there are none. In any case my main point is that assertions would be perfect if only they are checked at compile time.