News for hackers. Stuff that matters.
Re:A Week with Elixir (Joe Armstrong) by tombert on Thursday May 30, 2024 @08:03PM (#40530162)
I miss Joe, he was a super nice guy who always responded back to my dumb emails when I was first starting as an engineer asking for help with concurrent programming in elaborate detail. He didn't have to do that, but he did, and he was awesome for it.

Even in this post, he was able to be polite and still critical of Elixir, pointing out parts that annoyed him, but still ended it with positive praise.

Re:A Week with Elixir (Joe Armstrong) by asa400 on Thursday May 30, 2024 @09:08PM (#40530485)
I can’t second this enough. I never knew him personally but hung out around him at a few Erlang conferences and he was always incredibly kind and giving. He never knew it but he had a huge impact on me as an engineer.
Re:A Week with Elixir (Joe Armstrong) by behnamoh on Thursday May 30, 2024 @06:43PM (#40529574)
> The Three Laws of Programming Language Design

> What you get right, nobody mentions it.

> What you get wrong, people bitch about.

> What is difficult to understand you have to explain to people over and over again.

Re:A Week with Elixir (Joe Armstrong) by sbuttgereit on Thursday May 30, 2024 @09:09PM (#40530496)
One thing that I don't think gets recognized enough is, at least in my experience, how supportive the different BEAM language communities are of each other. As someone that spends time with Elixir, I find it encouraging for the whole BEAM ecosystem when I see some key people involved with Erlang commenting in and being generally helpful to people in the Elixir community over at the Elixir Forums with some frequency.

I know when I'm thinking of the ecosystem, I really think if it more in terms of the broader concept of the BEAM as being "the ecosystem", that common thread, rather than just Elixir, or Erlang, or LFE, of Gleam individually.

Re:A Week with Elixir (Joe Armstrong) by behnamoh on Thursday May 30, 2024 @09:23PM (#40530560)
What threw me off with Elixir was multiple inconsistencies, some of which documented in this article (btw, Elixir didn't fix the issue Joe mentioned about FORMS ≠ EXPRESSIONS).

Another one is this: When you first learn Elixir, you start to like the idea of calling functions from their types, like Tuple.product({2, 4}). Now if you want to get the size of a tuple, what do you do? Probably Tuple.size(...), right?

Wrong. You should use tuple_size(...)!

Turns out sometimes you gotta use these "orphan" functions even though they logically belong to a certain type (in this case, why isn't tuple_size called like Tuple.size or something?)

Re:A Week with Elixir (Joe Armstrong) by gamache on Thursday May 30, 2024 @09:51PM (#40530694)
> Turns out sometimes you gotta use these "orphan" functions even though they logically belong to a certain type (in this case, why isn't tuple_size called like Tuple.size or something?)

tuple_size/1 is a guard, and guards are built-in. The compiler itself uses them. Unlike regular functions, you are allowed to use guards in a function head, like:

    def foo(my_tuple) when tuple_size(my_tuple) == 3 do ...
Official docs: https://hexdocs.pm/elixir/1.16.3/patterns-and-guards.html#gu...
Re:A Week with Elixir (Joe Armstrong) by gamache on Thursday May 30, 2024 @10:01PM (#40530741)
Oh yeah, FWIW a "built-in" function or macro just means it's a part of the Kernel module, which is automatically required+imported in Elixir modules. So it's not orphaned, it's just in the one special module that gets brought in by default.
Re:A Week with Elixir (Joe Armstrong) by giraffe_lady on Thursday May 30, 2024 @10:34PM (#40530927)
Ahh, that's it. I said in a sibling comment that I had no idea why it was like that. But reading this made me realize that at one point I did know why! Completely forgot this bit of knowledge in the last year of not using the language.
Re:A Week with Elixir (Joe Armstrong) by manusachi on Thursday May 30, 2024 @10:07PM (#40530774)
I guess it has something to do with those functions frequently used in guards. _Notice tuple_size/1, map_size/1, byte_size/1 and some other functions/macros are defined in Kernel and documented in the section Guards[0]_

We can't invoke remote functions (which Tuple.size/1 would have been) in guards.

Though, there are some other functions that I can't think of a reason why they are "orphaned" such as put_elem/3 to put element into a tuple, while, for example, for maps there is Map.put/3

[0] - https://hexdocs.pm/elixir/Kernel.html#guards

Re:A Week with Elixir (Joe Armstrong) by giraffe_lady on Thursday May 30, 2024 @09:49PM (#40530683)
I didn't look it up for this one specifically but usually those are when elixir is just directly applying a function from the core erlang module (ie erlang global fns).

As for why they do that, rather than wrap them into the appropriate module, I have no idea. There may be a valid reason: for a language that is otherwise so careful about naming, organization, and consistency it would be a bizarre unforced error.

Some of them have nonstandard (for elixir) names and parameter order too so they are definitely one of the few unpleasant quirks of the language.