3 ms·
Your argument would be in favour of a defensive spec, not in favour of a defensive implementation. To explain: your spec will have a few hygiene clauses like '
by eru 9y ago
Your argument would be in favour of a defensive spec, not in favour of a defensive implementation.
To explain: your spec will have a few hygiene clauses like 'no stack overflow' or 'no crashes' and some things about what useful things the program should actually do.
The latter is hard to formalise and deserve defense in depth. Lots of the former are easy to formalise and you can rely on the compiler to get it right.
And that's what we are doing already anyway: even in C we just trust that a loop will compile to the appropriate conditional jumps and don't add defensive measures to check that.
- Aaargh20318 9y agoThe point is that you're not going to do formal verification of your software. There is actually very little formally verified software out there, and the verified code that does exist is relatively small. And no, you can't rely on the compiler to get it right. Maybe if you only write Haskell you can get there 99% but there will always be human errors in code that the compiler can't find.
- eru 9y agoWe rely on computers to get parts of our spec right all the time. Yes, a higher level language lets you offload more to the computer (like Haskell), but even in C we are doing some off that. Yes, in practice you seldom have much of a formal spec, agreed.