4 ms·
The question isn't whether you can do something in principle. It's whether the approach is more effective than alternatives. My experience is that it's not.
by yogthos 8y ago
The question isn't whether you can do something in principle. It's whether the approach is more effective than alternatives. My experience is that it's not.
- coldtea 8y ago>It's whether the approach is more effective than alternatives. My experience is that it's not. It obviously is more effective, since you can prove parts of your programs behavior throughout at compile time -- whereas contracts depend on passing through some particular code. Besides those are two different things. You can have types to do the heavy lifting AND contracts a la e.g. Eiffel
- yogthos 8y agoIt's only obviously more effective coming from a very narrow perspective. Static typing can provide stronger guarantees, but if it takes significantly more effort to do that and you already get adequate guarantees with contracts then that effort is likely not justified. The goal is typically to ship software that works well enough in a reasonable amount of time, and my experience is that contracts provide a much better tool for doing that. While contracts need to execute the code, generative testing provides you with a sufficient sample to be reasonably sure that the code is doing what you want. The contracts also let you directly specify what the code is intended to be doing, something that's not easy to do using the type system. In some situations proving parts of the program behavior may be worth the effort, but I simply don't agree that it's true for the general case.