Rant after trying Rust a bit

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 25 01:58:27 PDT 2015


On 7/25/2015 12:08 AM, Jonathan M Davis wrote:
> I must say that this is a rather odd argument to be having though, since
> normally I'm having to argue that 100% test coverage isn't enough rather than
> that code needs to have 100% (e.g. how range-based algorithms need to be tested
> with both value type ranges and reference type ranges, which doesn't increase
> the code coverage at all but does catch bugs with how save is used, and without
> that, those bugs won't be caught). So, having to argue that all code should have
> 100% code coverage (or as close to it as is possible anyway) is kind of surreal.
> I would have thought that that was a given at this point. The real question is
> how far you need to go past that to ensure that your code works correctly.

It's still unusual to have 100% coverage in Phobos, and this is not because it 
is hard. Most of the time, it is easy to do. It's just that nobody checks it.

Although we have succeeded in making unit tests part of the culture, the next 
step is 100% coverage.

I know that 100% unit test coverage hardly guarantees code correctness. However, 
since I started using code coverage analyzers in the 1980s, the results are 
surprising - code with 100% test coverage has at LEAST an order of magnitude 
fewer bugs showing up in the field. It's surprisingly effective.

I would have had a LOT more trouble shipping the Warp project if I hadn't gone 
with 100% coverage from the ground up. Nearly all the bugs it had in the field 
were due to my misunderstandings of the peculiarities of gpp - the code had 
worked as I designed it.

This is a huge reason why I want to switch to ddmd. I want to improve the 
quality of the compiler with unit tests. The various unit tests schemes I've 
tried for C++ are all ugly, inconvenient, and simply a bitch. It's like trying 
to use a slide rule after you've been given a calculator.

(I remember the calculator revolution. It happened my freshman year at college. 
September 1975 had $125 slide rules in the campus bookstore. December they were 
at $5 cutout prices, and were gone by January. I never saw anyone use a slide 
rule again. I've never seen a technological switchover happen so fast, before or 
since.)



More information about the Digitalmars-d mailing list