Erlang's biggest gotchas?

Tuples and lists are both indexed starting at 1, since you ask for the 1st element of something, not the 0th :slight_smile:

The 0 was only used by languages because it was a memory offset, so it doesn’t make sense for higher level languages and ones that are closer to/used for mathematics probably all start indexing at 1 since that is natural.

Of course, that doesn’t mean it isn’t a gotcha since many languages sadly adopted indexing starting at 0. Its just one of those things I like to rant about.

3 Likes

Honestly I think the big thing is that a lot of mix users don’t know how to use rebar3. Perhaps the rebar3 docs should have a page showing how to do mix stuff but using rebar, both commands and configuration, I bet that would help a lot of people how to understand and use rebar, plus would give a convenient link to give out for such posts. :slight_smile:

Really though, most elixir people don’t really understand how powerful rebar3 actually is.

I ask for the zeroth element of something in real life, have been since in early grade school near 40 years ago, 1 has always seemed weird to me, lol.

Plus, 0 is better to start with regardless for a number of reasons, this link is always a fantastic short summary:
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

4 Likes

Hehe, yea, Dijkstra. My dad is a mathematician so I too was accused of “pendatry” for once starting with 0 – I got started programming with C so it was all I knew. And that stuck with me :slight_smile:

2 Likes

Strings. the many flavor of the same string, the string literal that feel weird: <<"đŸ€Ș"/utf8>> anyone?

3 Likes

I’m sure I can come up with a counterexample that breaks this, too. But I guess you’ve got to draw a line somewhere. “Doctor, it hurts when I do this
”

2 Likes

Out of curiosity, is there a reason rebar3 isn’t just called rebar?

1 Like

Because “rebar” is rebar 2.x, and it’s still needed (though more rarely these days) for older projects. Elixir’s mix, for example, allows you to specify which one you want to use for dependencies.

4 Likes

There has long been interest in either moving rebar3 into Erlang/OTP or some other way to have them install together even if they are in separate repos and simply packaged together. Sadly it is a good bit of work.

Would it be that hard to add kerl support to rebar3? Then rebar3 could bootstrap your Erlang install.

2 Likes

As someone who is quite new to Erlang and who isn’t really a software dev, the toughest aspects of learning Erlang are thinking functionally and dealing with immutable data. I mostly work in Python these days and I have to think very differently about problems when trying to do something in Erlang, especially since most ways I would solve a problem involve some sort of mutable data.

But thanks to the usual books and the great folks over on the Erlang Slack #learning channel, it’s starting to click. I’m still very much a beginner, but I’m starting to get hooked.

2 Likes

We began rebar3 breaking backwards compatibility, it fundamentally changed the way rebar works. We didn’t want a completely new name since it would still use rebar.config (some compatibility was kept where it made sense) and we wanted to make clear it was the successor. Simply bumping the version and keeping the name wouldn’t convey how big of a change it was and as @rlipscombe points out it would make having both a litlte more difficult for users.

But I don’t know if any projects that are used today actually need rebar 2.x – as in there are surely repos on like github that still use rebar but just because they haven’t been touched in 10 years. And some of those will still work with rebar3, assuming they don’t rely on the port compiler or a rebar plugin but are just Erlang code.

I guess there is still couchdb which is still rebar and I believe has been planning to move to mix.

3 Likes

Yeah I get that semantically starting at 1 is valid, if I said “please raise your zeroth finger” it wouldn’t make much sense :slight_smile: I’m just dyed in the wool from past experience :stuck_out_tongue: I guess the reason I classed it as a gotcha is that after reading through LYSE and starting on some programming puzzles, it bit me in the ass and took me some time to figure out what was happening with my strings. Taking all the other languages I have worked in into account, this seems like an exotic thing, but its not loud and proud in the docs, so it tripped me up :slight_smile:

3 Likes