News for hackers. Stuff that matters.
Re:OTP at a High Level (2019) by Miner49er on Monday February 19, 2024 @02:12PM (#39433489)
I can speak on this a bit. I'm fairly new to Erlang, but the team I'm on has been using Erlang since before Elixir was created. So we've been doing Erlang just because it's what we've been using, and the team knows it, not Elixir.

However, we recently just decided to start new projects in Elixir rather then Erlang.

One argument a former team member would make against Elixir is that it has almost too many ways of doing things, in some cases. Erlang is a much simpler language. One example he used was sigils. Sure, they're nice, but it also means there's multiple ways to define a binary string, for example. Sometimes it is nice to have a single way to do something and not have to worry about making a decision about it. This example isn't great anymore though since Erlang is getting sigils in OTP 27.

Another argument I can think of is that Erlang is learning from Elixir. Erlang took its maybe expression from Elixir's `with`, and, IMO, the maybe expression is better. They're also adopting sigils.

But, like I said, we ended up deciding to go with Elixir for new projects, so I would be curious to see what reasons other people have for picking Erlang.

Re:OTP at a High Level (2019) by square_usual on Monday February 19, 2024 @02:29PM (#39433651)
What do you think is better about the maybe expression? Just curious, haven't looked into it too deeply and I thought it behaved exactly like when.
Re:OTP at a High Level (2019) by Miner49er on Monday February 19, 2024 @02:46PM (#39433856)
Well, I haven't written any Elixir yet, so I'm probably saying that without really knowing.

The main thing, and maybe I just am missing something, but I don't really understand what the point of the 'do' in Elixir's 'with' is? In Erlang you just have the maybe and anything that would go in that do block would just go inside the maybe expression. That seems a lot better to me.

I also just prefer the look of Erlang's maybe. I think maybe is a clearer name for what the statement is doing and the lack of the 'do' block looks better to me and makes it easier to read.

Re:OTP at a High Level (2019) by troupo on Monday February 19, 2024 @04:24PM (#39435002)
> I think maybe is a clearer name for what the statement is doing and the lack of the 'do' block

It's because basically everything in Elixir is a macro :), and the do block is an argument/parameter to that macro:

   maybe x do
      ...
   end

   # is really 

   maybe x, do: ...

   # which ends up being a macro call with a named parameter

   maybe(x, do: ...)

Same goes for many (all?) other things in Elixir:

   if x do
      ...
   end

   # is really 

   if x, do: ...

   # which ends up being a macro call with a named parameter

   if(x, do: ...)
And so on.

But it took me a very long to come to grips with this, too :)

Re:OTP at a High Level (2019) by square_usual on Monday February 19, 2024 @04:44PM (#39435183)
I think GP is talking more about the fact that you can have a do block, not about what it is.
Re:OTP at a High Level (2019) by Miner49er on Monday February 19, 2024 @05:03PM (#39435370)
Yeah exactly, in Erlang the 'do' portion would just go in the same code block as the conditionals.
Re:OTP at a High Level (2019) by nesarkvechnep on Tuesday February 20, 2024 @02:08AM (#39438726)
So you say `maybe` is better than `with` without ever using Elixir, and `with`? I hope your team is not full of people making blanket statements like this.