[erlang-questions] Time for OTP to be Renamed?

Richard Carlsson <>
Thu Feb 13 15:59:39 CET 2014


On 2014-02-13 15:19 , Dave Cottlehuber wrote:
> Thanks Fred,
>
> An insightful response. Where do you see behaviours in all this?
>
> The context is that I've recently advocated introducing behaviours
> very early on (not full gen_* behaviours), but just as a really simple
> step in learning erlang, same as adding tests, using typer & dialyzer,
> in helping enforce API contracts between modules. It seems to ease the
> shock of the first encounter with gen_server etc, removing a bit more
> of the black magic up front.

Not Fred, but:

First, -behaviour(...) declarations are quite low level in themselves, 
just being an API specification that the Erlang compiler happens to know 
how to check at compile time (if the module that defines the behaviour 
is present at that time). And an Erlang compiler could ignore the 
declaration without any real ill effects - it's just a help to discover 
errors. From that viewpoint, behaviour=interface.

 From the OTP viewpoint however, "behaviour" implies that along with the 
interface there is an associated library with generic functionality, 
typically implementing a process or set of processes, which you 
specialize by providing your API-conforming callback module. (Although 
these days, some who implement their own behaviours only use them for 
the interface part, and don't actually have a generic component.) This 
concept, is one of its main foundations of OTP (but is independent of 
the rest of OTP). The interface checking is sugar on top.

     /Richard



More information about the erlang-questions mailing list