Assert() in the hands of bad coders
Using assert() creates better code, as programmers double-check assumptions. But only if used correctly. Unfortunately, bad programmers tend to use them badly, making code worse than if no asserts were used at all. They are a nuanced concept that most programmers don't really understand.We saw this recently with the crash of "Bitcoin Unlimited", a version of Bitcoin that allows more transactions. They used an assert() to check the validity of input, and when they received bad input, most of the nodes in the network crashed.
The Bitcoin code is full of bad uses of assert. The following examples are all from the file main.cpp.
Example #1: this line of code:
- if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull())
- assert(false);
This use of assert is silly. The code should look like this:
- assert(nPos < coins->vout.size());
- assert(!coins->vout[nPos].IsNull());
This is the least of their problems. It understandable that Continue reading

Containerd has been the heart of the Docker platform since April 2016.
Network virtualization will allow companies to micro-segment traffic by application.