Why don't other programming languages have ranges?

dsimcha dsimcha at yahoo.com
Tue Aug 3 07:35:52 PDT 2010


== Quote from Don (nospam at nospam.com)'s article
> If you have two buggy pieces of code,
> but they are completely independent, their bugs will manifest on
> different inputs. So you can achieve extremely high reliability even on
> code with a very high bug density.
> I find it particularly interesting that the Pentium FDIV flaw was
> detected by comparison of Pentium with 486 -- even though the comparison
> was made in order to detect software bugs. So it is a method of
> improving total system reliability.
> I've not heard this idea applied to software before. (Though I vaguely
> remember a spacecraft with 3 computers, where if one produced different
> results from the other two, it was ignored. Not sure if the processors
> used different algorithms, though).

I often exploit this for code that's otherwise very hard to unit test.  If I have
a very complex algorithm with about ten zillion code paths to compute something,
and manually coming up with test cases for all possible paths would be near
impossible, I often devise a simpler algorithm that's either much slower, makes
different tradeoffs or is only an approximation, and test both against each other
on tons and tons of random data to make sure they get the same answer (or roughly
the same in the case of the approximation algorithm).  I've found tons of bugs
this way that I probably would never have found any other way.

For example, let's say you're writing a new hash table implementation with
optimizations for some specific use case.  One easy way to test it would be to
feed it random data and feed the builtin AA the same random data, and see if they
end up in the same state.


More information about the Digitalmars-d mailing list