[erlang-questions] Any Erlang Devs Contemplating Elixir?

Robert Virding rvirding@REDACTED
Sun Mar 6 05:03:32 CET 2016


One definite benefit in having to explicitly write every callback even if
it is doing "default" stuff is that everything *IS* then explicit and you
can directly SEE what happens. And come on, writing a 2 line default case
for a few callbacks is really not that much to extra code.

A major problem with having implicit "default" cases is that what people
consider to be a reasonable default handling varies depending on what just
that server is doing. There is no default that suits every server so I will
probably have to write it out and anyway.

Hiding callbacks behind defaults also means that you don't SEE everything
that is there. This can be a major problem for newcomers.

Robert


On 27 February 2016 at 11:54, Loïc Hoguin <essen@REDACTED> wrote:

> On 02/26/2016 10:27 PM, Onorio Catenacci wrote:
>
>> While there may be other considerations you want to keep in mind,
>> there's one, to my mind, major point that's been neglected in the
>> discussion of using Elixir: macros.
>>
>> I have been led to understand by people far more familiar with Erlang
>> than I am that in order to use certain behaviours from OTP one has to
>> write boilerplate code for several callbacks whether one wants to modify
>> the behavior from defaults or not.
>>
>> Elixir's macros allow the library to provide default implementations for
>> these callback functions.  Of course a developer can override the
>> defaults if needed but not having to code what I don't need strikes me
>> as a big advantage--especially if we're discussing a new developer who
>> doesn't already know either Erlang or Elixir.
>>
>
> I'm not even sure what makes you think you need macros to provide default
> implementations? You don't. The gen_server for example has an optional
> callback with a default implementation: format_error. That it doesn't
> provide defaults for other callbacks is purely a design choice, and not a
> limitation of the language. You could trivially extend gen_server to make
> all callbacks optional, no need to have macros for that...
>
> --
> Loïc Hoguin
> http://ninenines.eu
> Author of The Erlanger Playbook,
> A book about software development using Erlang
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160306/40e1be3f/attachment.htm>


More information about the erlang-questions mailing list