Live data from Hacker News

How I fell in love with Erlang

boragonul.com

121–130 of 263 posts

Re: How I fell in love with Erlang

#121

> “How can you sum the numbers from 1 to 10 without using a loop?” ... And there it was: recursion. Wait, is there something I don’t actually understand about recursion? When a recursive function calls itself, is that not a loop?

It depends on how technical you want to get. It's certainly not a loop in the classic sense, like a for loop etc. Like there are no `continue` or `break` semantics and you can't return out of it (and yes yes of course you can still do all that stuff, just not with dedicated keywords). I call it a loop, though. Whenever I make a lil' server in Elixir (mostly always for teaching) I always call the function `loop`:

    defmodule Server do
      def start_link do
        spawn_link(&loop/0)
      end

      defp loop do
        receive do
          msg ->
            IO.puts(msg)

            loop()
        end
      end
    end

Re: How I fell in love with Erlang

#122
post #7

It's funny how HN goes through these Erlang cycles. It's a long standing tradition, starting off with 'Erlang Day': https://news.ycombinator.com/front?day=2009-03-11 Erlang gets a lot of stuff right for scalable web based stuff, and even though there are many of its influences that have by now made it into other languages and eco systems it is still amazing to me that such a well thought out system is run with such i…

Unfortunately, I have to disagree on the absolute notion, that you will never see someone being not nice in the Erlang world. OK, you technically said "behind Erlang", not "in Erlang ecosystem". But in the Erlang ecosystem and related languages I've had at least 2 encounters, that were not nice. One outright called lack of good documentation for some projects in the Erlang ecosystem bullshit in a public chatroom, and it killed all my motivation to continue exploring that part of the ecosystem, the other one probably without knowing gave low effort dismissive responses to questions about how to best do something, without even knowing the context in which my code appeared, mixing in their personal taste and treating me like a little child.

So there are definitely unpleasant people around, just like in many ecosystems. Maybe less so, but I don't know about that. The question is only whether one lets that keep one from doing whatever one came to do.

Re: How I fell in love with Erlang

#123
post #18

I can totally relate to this. Programming in Erlang felt so natural compared to the knots I was twisting myself into writing C++. I was churning out C++ code, but wasn't having fun. Suddenly Erlang made it fun and programming became addictive.

> Suddenly Erlang made it fun and programming became addictive. I'm saying this with complete sincerity: WHAT IS IT THAT YOU PEOPLE SEE!? What is the fun? What are you addicted to? Typing and seeing the output? Solving a problem? I feel like I am missing out on some amazing life altering experience when I see people state that. The same thing I have with the article - what does it mean to love a programming language?

It's kind of like this:

https://xkcd.com/224/

Also this:

https://www.infoq.com/presentations/Simple-Made-Easy/

For me, there's a dopamine hit in taking a complex problem, and breaking it into simple interacting parts that solve the problem in an elegant way. Overly complex programming languages add lots of incidental complexity that slow down this process. A clear, simple, consistent semantics accelerate this process.

If that doesn't inherently excite you, the life altering experience probably isn't going to happen for you.

Re: How I fell in love with Erlang

#125

I used Erlang for a couple of years. It's cool and elegant for sure, but it always felt like it took longer to write than JS or Py like I'd otherwise use. Recursion with matchers is sometimes natural, sometimes roundabout to what you want to do. The multiprocess stuff is cool too, but a premature optimization for what I was doing. If I needed to scale, I don't know if that'd be the chosen approach.

I do a lot of Elixir programming, which is different and not at the same time :-) . What I find is that it takes me longer to write the initial code than I might in, say, JavaScript, but that the refactoring and ongoing maintenance of code is significantly faster. This is because I think the functional & actor paradigms force you to think harder upfront, but once those decisions are made are easier to manipulate. For…

Thats interesting. In my case, elixir does take a longer time. Probably because i dont get used to or just use it not as frequent as other languange.

Would you mind telling me your elxir program about? Is it a webapps or something similar?

Re: How I fell in love with Erlang

#126
post #69

For what it's worth, I'm stuck on the very first x = x + 1 thing. Not sure if you want to call it a screwup or bad grammar or whatnot, but it is perhaps the huge mistake that the "equals" sign was used for something that feels like, but emphatically DOES NOT mean, "is equal to." It's "put this into that". It's an action verb. Should have perhaps insisted on x x

[deleted]

Re: How I fell in love with Erlang

#127
post #31

My confusion here is it always seemed liked a simple mapping to take = to mean "make x equal to x+1" rather than "x is already equal to x+1". It is declaring a relationship, between the previous value and the current. One way or another, youre defining transformations. I mean even in the sum example, you see the statement "N is n-1" which is the exact same thing as x = x+1 with = swapped for "is"

> even in the sum example, you see the statement "N is n-1" That wasn't actually what the example said. It said N1 = N - 1, and continued using the N1 value somewhere else. In that example, no actual mutation occured.

Oh my weary eyes, my bad

Re: How I fell in love with Erlang

#128

I want to get into Erlang, but I also know a lot of languages that are cool, effective, but rarely used in jobs.

That's the downside. If you look at the monthly "who is hiring" posts here on HN, you rarely see Erlang jobs. Elixir shows up a bit more often but it's still uncommon.

Re: How I fell in love with Erlang

#129
post #69

For what it's worth, I'm stuck on the very first x = x + 1 thing. Not sure if you want to call it a screwup or bad grammar or whatnot, but it is perhaps the huge mistake that the "equals" sign was used for something that feels like, but emphatically DOES NOT mean, "is equal to." It's "put this into that". It's an action verb. Should have perhaps insisted on x x

That’s funny, because to me, it was always immediately obvious that once that line runs, then it must be true - once that line runs, x is now equal to whatever it was before, + 1. It’s the price opposite of the lie, it’s the literal definition of truth, in the sense that what is true is set by that line. Programming is telling things to the computer, and in this case, you’re telling it what x is. Whatever you tell a…

> once that line runs

This is the key point. Some people have a mental model that algebraic syntax is describing a set of immutable properties. You are defining things and giving them names, but not changing anything. There is no notion of time or sequence, because the universe is unchanging anyway. All you're doing is elucidating it.

Then there is a model where you are molding the state of a computer one imperative modification at a time. Sequence is essential because everything is a delta based on the state of the world before.

You have the latter model, which is indeed how the hardware behaves. But people with a mathematical mindset often have the former and find the latter very unintuitive.

Re: How I fell in love with Erlang

#130
post #69

For what it's worth, I'm stuck on the very first x = x + 1 thing. Not sure if you want to call it a screwup or bad grammar or whatnot, but it is perhaps the huge mistake that the "equals" sign was used for something that feels like, but emphatically DOES NOT mean, "is equal to." It's "put this into that". It's an action verb. Should have perhaps insisted on x x

> It's an action verb.

The difference is that it is an instruction. Conventional mathematical notation, while declarative by default, switches into instruction mode just the same with the "let" keyword. The usage of the "=" operator then becomes equivalent: e.g. let x = 1.

But as the aforementioned x = x + 1 comes from notations that are never declarative, where every statement is an instruction, the "let" keyword is unnecessary and redundant. You already know you are looking at an instruction.

> Should have perhaps insisted on x x

While that would obviously work, it strays further from the conventional notation. Which doesn't matter to the universe in any way, but the topic of discussion here is about trying to stay true to conventional notation, so...

Post reply on HN