I Fell in Love with Erlang

(boragonul.com)

142 points | by asabil 10 days ago ago

58 comments

  • jacquesm 3 hours ago ago

    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 incredible modesty. You'll never see the people behind Erlang be confrontational or evangelists, they just do what they're good at and it is up to you whether you adopt it or not. And that is an interesting thing: the people that are good at this are writing code, not evangelizing. If I had to reboot my career I'd pick this eco system over anything else, it has incredible staying power, handles backwards compatibility issues with grace and has a community that you can be proud of joining. Modest, competent, and with a complete lack of drama.

    • noir_lord 2 hours ago ago

      > You'll never see the people behind Erlang be confrontational or evangelists, they just do what they're good at and it is up to you whether you adopt it or not.

      The big open source projects where pretty much all like that in the past, in the 80's/90's/early 2000's - in that respect they feel like a pleasant anachronism before everything needed to be promoted/self-promotional influencer like, the users did the evangelism but the creators where usually much more chill.

      Obviously the vast majority of open source projects are still like that but there is definitely a lot more in your face promotion of things that feels different somehow almost aggressive/corporate style even when there is no paid product.

      Not knocking the ones who do it, if it's open source they can sing it from a mountain top for all I care, the license it's under matters more.

      • isodev an hour ago ago

        I think what has changed mainly is that today we have tools, languages and entire ecosystems that exist only as means to support someone’s product line.

        Take Swift for example. A giant gatekeeper of a corp decided to make it the only (reasonable) way to build apps and so it exists, powered by countless indie developers constantly creating content around it. Would Swift be a thing without everyone being forced to use it? I don’t know, but I don’t think so.

        So in some ways we’ve traded unique and effective solutions to “popular and mainstream” things that scream the loudest. You wouldn’t get fired for choosing Swift. Or Azure.

      • kace91 an hour ago ago

        >somehow almost aggressive/corporate style even when there is no paid product.

        For those who collaborate with open source for political/ideological reasons (which does not need be the case), it makes sense to join the battle for attention.

        As long as the product isn’t compromised in the way, I think it’s very good to see open source influencers.

        • pxc 12 minutes ago ago

          GNU Guix has a good blog, but I don't feel like they are very "marketing" focused.

          It's hard to describe precisely, but a lot of free software projects do a good job of putting themselves out there in an unfussy way. There really is something refreshing and cozy about that.

      • actionfromafar 2 hours ago ago

        I think it's because we are wired that attention is it's own currency nowadays. And it's also true. Even if there's no paid product, you get strength in numbers. If you depend on an open source library, it's usually better for you if others depend on it too.

        • noir_lord 2 hours ago ago

          Certainly an element of that but there are also cases where the superior product "lost" to the inferior product because the inferior one was better marketed.

          So doing some level of promotion becomes necessary if you want users even when you have the better product - the superior product speaks for itself doesn't often apply any more.

    • mycall 5 minutes ago ago

      Does anyone know if matrix.org has any Erlang implementations? It seems like the perfect fit to me.

    • marceldegraaf 3 hours ago ago

      It's funny that you mention this, and it made me take some time to appreciate I've been working with Elixir full-time for almost 10 years now, and the entire experience has been so... stable.

      There's been little drama, the language is relatively stable, the community has always been there when you need them but aren't too pushy and flashy. It all feels mature and – in the best possible way – boring, and that is awesome.

      • noosphr 2 hours ago ago

        I've moved from Linux to OpenBSD for this reason.

        It's all so boring it's wonderful.

      • zwnow 27 minutes ago ago

        For me it took a tremendous amount of work to somewhat understand the OTP stuff though. Its one of those languages where I can never be confident about my implementations, and thankfully it has features to check whether you have stale processes or whatever. A language I am humbled by whenever I use it.

    • sph 2 hours ago ago

      I don't think it's cycles, more like newcomers rediscovering the future.

      I've learned Elixir in 2016 after a lull in my interest in programming languages, and 9 years later it's still my favourite environment by a country mile. It's not the language per se, but the BEAM, the actor model, the immutability — just makes sense, and doing things the C/Rust/Javascript/Python way is like building bridges out of cardboard.

      For example, I've stepped into the world of game dev and Godot, which is fantastic and uses a regular object-oriented model. After trying to build a non-trivial desktop app with it, my thoughts are consumed by the fact that mutable state and object orientation is the silliest idea, and I'm speaking as someone that really got into Smalltalk and message-passing objects.

      I don't even need actors and OTP, I just want some immutable data structures and functions operating on them. Erlang/Elixir are fantastic to build servers, but there is a sore lack of something closer to the metal within 80% the speed of a native language. I would build an entire operating system out of it. Why has no one put microkernels and Erlang into a blender? I know there's QNX, but it's still UNIX, not Erlang.

      • mycall a few seconds ago ago

        What about OCAML, does that fill your needs?

    • SeanDav 2 hours ago ago

      I am just wondering when the next "We-Love-Haskell" cycle is going to start!

    • rat9988 an hour ago ago

      Nice write up. Thank you for taking time to evangelize it.

  • macintux 11 minutes ago ago

    I discovered Erlang from Bruce Tate's book[0] and it was such an obviously pragmatic and interesting language that I started participating in the Twitter Erlang community, discovered Basho was using it for Riak and looking for a tech evangelist in the Midwest, and thus began my all-time favorite job.

    I'm still more of a infrastructure guy than a software developer, but working with such incredibly smart people was a delight. Basho was good at hiring people who could learn Erlang (and, perhaps unsurprisingly, was almost entirely remote).

    [0]: https://pragprog.com/titles/btlang/seven-languages-in-seven-...

  • donatj 2 hours ago ago

    > X equals X plus one? That’s not math. That’s a lie.

    That's really interesting... My wife, who has no real mathematical background had the EXACT same reaction when I was trying to teach her some simple programming. I tried to explain that equals in that context was more of a storage operator than a statement that said line is true. She found it very frustrating and we gave up on the endeavor shortly thereafter.

    I've personally always had a soft spot for languages like TI-BASIC that use a storage operator rather than overloading = so for example:

    X + 1 -> X

    I wonder if I should try a functional language with her.

    • davidsainez an hour ago ago

      I highly recommend How to Design Programs. I recall being repeatedly mind blown working through the book. It was great fun. The authors start by composing pure functions. IIRC you get quite far before you have to do any mutation. Take a look! https://htdp.org/2003-09-26/Book/curriculum-Z-H-5.html

    • npteljes an hour ago ago

      Pascal also had := for assignment, if I remember correctly. I disliked it, to be honest, = is pretty much universally accepted in the IT world to mean "assign to".

      I don't think this is something that keeps someone from programming. If it does, then the other 100000 hoops won't be better, every trade has its "why the fuck is this the way it is" moments.

      If you'd still try programming with her, I think you could start with a visual programming thing. Maze from Blockly Games is a simple online logic game that can be overcome with visual programming. No need to register or anything. The levels get progressively harder, as it teaches to apply programming concepts, and makes the player combine them. As a programmer, I found the game really fun, and I think it's suitable for beginners as well, seeing how for example LEGO used a very similar system for its programmable sets.

      https://blockly.games/maze?lang=en

    • ngriffiths an hour ago ago

      I think it makes more sense in languages where you use the "let" keyword. Then it sounds like assignment, though you still have to get comfortable with the X being on the right side too.

    • macintux 18 minutes ago ago

      I've shared it here once recently, so might as well again.

      I gave a talk at Midwest.io (sigh, such a great conference, shame it faltered) building Erlang from the ground up, starting with the = sign and the implications (side effects?) of it being a runtime assertion of truth in addition to a binding.

      https://youtu.be/E18shi1qIHU

    • SeanDav 2 hours ago ago

      It is not a lie it is just apparently familiar notation that actually has an entirely different meaning. It is not an equation, it is an assignment.

      X := X + 1 is perhaps less confusing, even if meaning the same thing.

      • npteljes an hour ago ago

        That's exactly right. Looking at the Assignment Operator Wiki page, it's also clear where these notations come from.

        I think an easy way to look at it, for someone coming from a math background, is to think of programming lines as instructions, instead of statements. x=x+1 can be then read as "let x be x+1", and that's it.

        https://en.wikipedia.org/wiki/Assignment_(computer_science)

  • mrkeen 3 hours ago ago

    The hyperbole that Haskellers invoke around pure-functional vs impure is that you're never quite sure whether a function call you make will "fire the missiles".

    It's colourful language, but it's just a stand-in for other properties you might care about. For instance, in head(sort(list)), will the whole list be sorted, or will the smallest element be returned? In atomically(doThis(); doThat()), will doThis be 100% reverted if doThat fails? If you stick to pure functions (and in the second example, STM) then you can unfire the missile!

    AFAIK, Erlang just fires the missile "over there", not "over here". The author jumped from:

      (X = X + 1) is bad
    
    to

      (mailbox = mailbox + message) is so simple!
    
    I'm not bashing the BEAM, or the ease with which one can send messages (as an Actor language), but I am complaining about the lack of tooling to write non-missile-firing functions on a single node (as a Functional language).
    • bargainbin 2 hours ago ago

      > (mailbox = mailbox + message) is so simple!

      The author did not say this at all, they barely even touched on capabilities of erlang/OTP. Their focus was on the functional syntax of Erlang.

      > For instance, in head(sort(list)), will the whole list be sorted, or will the smallest element be returned?

      Your point isn’t clear. The functions have a clear nested call sequence, take a list, sort it, get the head.

      Also how is it any different than Haskells `head (sort list)`?

      • ctenb 2 hours ago ago

        In Haskell with `head (sort list)` the entire list does not have to be sorted, depending on the sort implementation. Everything is lazy, so sort can sort the list just enough to return the smallest element.

        • auggierose 2 hours ago ago

          Going beyond laziness, a compiler that can understand and exploit equations, could use `head (sort list) = smallest (list)` to make the program more efficient, going from O(n * log n) to O(n) complexity.

      • mrkeen an hour ago ago

        > The author did not say this at all, they barely even touched on capabilities of erlang/OTP.

          Two separate Erlang nodes. On different machines, different networks, different continents if I wanted. And they could just… talk. No HTTP. No REST API. No serialization headaches. Just message passing. Just actors doing their thing.
        
        > Their focus was on the functional syntax of Erlang.

        They didn't write any Erlang until the ping/pong example, which doesn't have any functions. What does pong() equal? Is it equal to itself even? What's its domain and range? If I wrote a unit test for it, what test inputs would I give it and what outputs would I assert?

      • petrzjunior 2 hours ago ago

        I think the question is whether sort should return a new, sorted array or whether it should sort the array in place. In functional languages it is the former, in imperative the latter.

        • knome 30 minutes ago ago

          It can be quite useful to have nondestructive sorting in imperative languages as well. Hence python introducing 'sorted' even though '.sort()' preceded it.

  • sam-cop-vimes 2 hours ago ago

    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.

    • tommica 2 hours ago ago

      > 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?

      • christophilus 2 hours ago ago

        It’s a subjective thing, but when a language clicks for you, work becomes pleasant. You get into (and maintain) a flow state. It feels as if you’re crafting something beautiful and elegant and simple. It’s the same reason people love painting, drawing, or sculpting with one specific medium over an other. They just like the aesthetic and process better.

        Also, some languages just really stink— slow compilation times, obscure errors, loads of footguns and require much more care and focus on things which are orthogonal to the problem you’re trying to solve.

      • sam-cop-vimes 2 hours ago ago

        I'll try and answer this.

        Expressiveness: I could express a solution to a problem with very few lines of code and without the clutter of housekeeping operations like memory management.

        Recursion: Erlang properly introduced me to recursion whereas I hadn't encountered it before. This is again related to expressiveness. There is something strangely beautiful about seeing a problem solved using recursion elegantly.

        Message passing: when I was trying to figure out how Microsoft's C++ socket classes were implemented and I dug into the code, it turned out there was a hidden window for every socket created and messages were being passed to/from it, but message passing wasn't available anywhere in Visual C++ as a first class construct (at least as far as I remember it). I was overjoyed when I discovered that message passing was a first class citizen in Erlang and how much easier it was to implement concurrent programs than using native threads in C++.

        Compared to OO programming in C++ where I was never sure whether I was using inheritance correctly, whether I needed inheritance at all, memory management, difficulty with threads, writing code in Erlang was a breeze.

        And the whole support for distributed programming, hot code loading, list comprehensions! I fell in love again with Erlang when I discovered list comprehensions. Man, I could go on.

      • knome 23 minutes ago ago

        when I program, I am visualizing the machine I am building in my head. some language semantics are cleaner than others, allowing the bits and pieces to flow together more naturally, composing in elegant ways that do not require pointless effort be spent manually wrangling footguns and minutia.

      • cmoski 2 hours ago ago

        Solving problems I guess. Have you used painful languages before? Imagine doing that, then discovering one that wasn't getting in your way all the time. It's easier to do things that are difficult in other languages. You can do so much on the BEAM, and you don't have to waste your time with thread pools or other nonsense.

  • imglorp 32 minutes ago ago

    > “How can you sum the numbers from 1 to 10 without using a loop?”

    Sum = n(n+1)/2

    • KingMob a few seconds ago ago

      Yeah, I assume it's missing some context that the numeric solution was off the table.

  • ctenb 2 hours ago ago

    I think the older programmer was hinting at gauss's formula with the summing 1 to 10 without using a loop? Recursion is also a loop in some sense.

  • az09mugen 9 days ago ago

    Unrelated to the topic, but I really like the feature `> cd ..` at the bottom of the article. It's simple and accessible even with a smartphone. I wonder if there is an easter egg inside.

    • darkwater 2 hours ago ago

      Because the homepage has this "interactive terminal" which is funny and nice (kudos for readline shortcut support) but also partially "broken", i.e. the blog post(s) and other links you see with "ls" are not clickable, at least on Firefox.

    • ramon156 4 hours ago ago

      I'd also love a `cd -` on the top left

  • bishabosha an hour ago ago

    this whole article stinks of AI prose, why should i read it

    • croisillon an hour ago ago

      the author loves Erlang, but not to the point of writing their love themself

  • andoando 2 hours ago ago

    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"

    • davidsainez 2 hours ago ago

      It is difficult to understand the full beauty (or horror, depending on your pov) of functional programming with such a simple example. But as you scale up in complexity, it can be someone’s full time job to make sure the model is accurately translated to the computer’s memory. With a pure language, the compiler is responsible for maintaining the mapping to memory, so you (mostly) just focus on the symbolic relationships of your model. This can be extremely freeing once you train yourself to think in functional terms. Of course, there is a performance cost, but this can be managed and in cases where people turn to functional programming reliability and correctness outweigh the cost.

      • fpoling 37 minutes ago ago

        Pure languages still use stack to store mutating state. In a single-threaded programs this is almost non-observable except for occasional stack overflow crashes. But with multiple threads and message passing one can emulate arbitrary state mutation just by using messages and stack.

        Then I have found the code that is a heavy user of closures is harder to understand even if it is single-threaded and closures can pass arbitrary state even if the state is immutable.

        What I have found useful is persistent data structures. Those really simplify modelling. But then those can be used in imperative languages as well.

    • lionkor 2 hours ago ago

      That's why I like the

          x := x + 1
      
      syntax better, or the

          let x = 2;
      
      syntax
    • ceayo 2 hours ago ago

      > 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.

    • mrkeen 2 hours ago ago

      It's N1 is N - 1, not N is N-1

  • nakamoto_damacy an hour ago ago

    Will it ever run in WASM?

    EDIT: there is Lumen, but not sure if it's stalled or still going.

  • abrookewood 4 hours ago ago

    Great article & I love the command line interface on the home page.

  • Gleamball 8 days ago ago

    Great talk i love it and thanx for sharing.

  • vortegne 4 hours ago ago

    Nice post, looking forward to more!

  • 4gotunameagain 2 hours ago ago

    Calls a simple swap function with pointers inscrutable (the only hard to decipher character is the asterisk), and as a good counterexample provides this ?

      -module(ping).
      -export([start/0, ping/1]).
    
      start() ->
          register(ping, spawn(fun() -> ping(0) end)).
    
      ping(Count) ->
          receive
              {pong, Pong_PID} ->
                  io:format("Ping received pong (~p)~n", [Count]),
                  Pong_PID ! {ping, self()},
                  ping(Count + 1)
          end.
    
    I am not against functional programming, or using the tools you love, but at least make a valid argument about it ;)
    • mrkeen an hour ago ago

      Port ping.erl and pong.erl to C and we'll compare them.

      • 4gotunameagain an hour ago ago

        But I am not contrasting the two languages, I'm very aware of their respective strengths and weaknesses.

        I am just disagreeing with the fact that C is hard to parse.

    • cess11 2 hours ago ago

      They didn't make such an argument. It's a biographical rumination about the authors personal development and feelings.