[erlang-questions] Re: Using -spec for callbacks when defining behaviours

Vlad Dumitrescu <>
Fri Mar 19 12:25:36 CET 2010


On Fri, Mar 19, 2010 at 00:46, Steve Davis
<> wrote:
> I'd temper this with the known effective approaches:
> 1) "let it crash"
> 2) apply checks only at the application/system boundary
> ..to which I'll add...
> 3) beware any form of cruft.

Hi Steve,

I'd like to amend number 2 above by replacing "application/system"
with "component". There might be an internal structure to an
application, if it is complex enough.

These approaches are indeed effective, but there are use cases where
it's more efficient to do checks before run-time. It's all a matter of
where the break-even is for the amount of effort spent debugging
problems at run-time vs specifying constraints at compile time. And
this break-even depends on the specific application's complexity and
architecture.

To put it another way, "let it crash" is a strategy for handling
errors, so that hopefully the user doesn't even realize there was a
problem. But the problem is still there. The static tools are helping
us to make sure that certain types of errors can't occur, including
subtle errors that don't cause crashes.

In my view, this kind of specification falls under the same category
of bug prevention as the compiler warning for the expression "5 + O"
(where the latter term is a big-oh, not a zero) that is going to cause
a run-time exception. It is more effective to catch that before
running and also you catch all these problems in all your code base
once you enable the warning.

best regards,
Vlad


More information about the erlang-questions mailing list