[erlang-questions] Why we need a -module() attribute?

Loïc Hoguin <>
Mon Feb 22 13:33:37 CET 2016


On 02/22/2016 03:28 AM, Steve Vinoski wrote:
>
>
> On Sun, Feb 21, 2016 at 8:38 PM, Loïc Hoguin <
> <mailto:>> wrote:
>
>     Regardless of the technical merits of one or the other solution,
>     when developing software it's generally a good idea to listen to
>     what you users want, and this Nth topic about -module should be a
>     clear indication that the current situation is not what many users want.
>
>     It doesn't matter if you think you are technically correct, because
>     you defend a point of view that many people do not care about. All
>     solutions have their strong and weak points, and enough people are
>     annoyed by the current solution's weak points (the mandatory -module
>     attribute) to create topics every couple months. People tend to want
>     different things, so when so many people agree on something it's
>     time to take notice. This happens a lot less than you'd think.
>
>
> I don't recall seeing this topic come up "every couple months". Can you
> provide pointers to the various threads where this has come up so often,
> other than this one, to back up this claim? Google searches of
> erlang.org <http://erlang.org> and searches through stackoverflow.com
> <http://stackoverflow.com> don't turn up much at all on this topic.

I guess it bubbles up to the ML less often than I thought. I still run 
into people having issues with it every couple months. I never know what 
to answer when they ask why it's this way, it just feels unnecessary to me.

>     In general it's also a good idea to remove as many steps as possible
>     to get code up and running, if only to give the illusion of Erlang
>     being a productive language, as this attracts newcomers much more
>     easily.
>
>
> Over the years I've heard reasons for people avoiding Erlang, but I
> personally have never even once heard someone say they didn't want to
> use Erlang because of the burdensome -module attribute.

People don't come to Erlang in droves because Erlang does not match 
their identity, ie it's not C/Java, Python or Ruby and does not have 
this familiar feeling. That's the *only reason*. Any other reasons given 
is just rationalization after the facts.

The people who do come to Erlang have to jump a lot of barriers to get 
comfortable with it. Common issues involve unnecessary steps (this is 
where -module comes in) and missing functions for simple tasks (when 
this comes up this involves strings or binary strings). Some people can 
jump all barriers no problem, others eventually fall and give up after 
falling a few times. Removing barriers help.

To give an example, PHP has so few barriers *to start* that even 
non-programmers can easily start doing things with it. They write a few 
lines, load up their browser and it prints things. The equivalent in 
Erlang involves a PhD... Of course PHP has a lot more barriers later on 
so I am not saying Erlang should be more like PHP, I am however saying 
that Erlang should be as easy to get started with as possible.

You're going to suggest that I dedicate time to improve these things but 
I already do and my time is not infinite.

Making the .app.src optional in Erlang.mk was the largest improvement. 
Before, people either forgot to list their apps to the 'applications' 
list, or made mistakes when adding them. Now they don't need to and no 
mistakes can be made.

I have a great deal of similar simplifications coming up in Cowboy 2, 
again to make things easier and avoid mistakes (removing barriers).

>     Erlang is the most productive language I've seen (in large parts due
>     to readability and low maintenance) but it's doing a terrible job
>     showing it.
>
>     We often say Erlang makes hard things easy and easy things hard.
>     Perhaps it's time to seriously consider making easy things easier.
>     This is the best way to get more people in. But I get the feeling
>     not everyone wants that, considering how little effort is spent on
>     that end (maps happened, but it seemed more like a miracle than
>     anything).
>
>
> IMO that statement is rather insulting to those who've put a lot of time
> and effort into designing and implementing maps. It's not at all a
> simple problem.

I really doubt Bjorn-Egil will be offended considering the discussions I 
had with him. I still maintain it's a miracle, and will add that he is 
the savior who made the miracle possible. I doubt we would have maps now 
if not for him. He knows how grateful I am for all his work.

> If having an optional -module attribute is that important to you, write
> a pull request.

There's not even the slightest hint that it would get accepted. My time 
not being infinite, I better spend it elsewhere for now. It's just one 
of many barriers.

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang


More information about the erlang-questions mailing list