Live data from Hacker News

How I fell in love with Erlang

boragonul.com

31–40 of 263 posts

Re: How I fell in love with Erlang

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

Re: How I fell in love with Erlang

#32

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"

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.

Re: How I fell in love with Erlang

#33
post #22

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

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.

Re: How I fell in love with Erlang

#34
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 ;)

Re: How I fell in love with Erlang

#35
post #8

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% r…

> (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…

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.

Re: How I fell in love with Erlang

#36

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 functiona…

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

Re: How I fell in love with Erlang

#38
post #8

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% r…

> (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…

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

Re: How I fell in love with Erlang

#39
post #22

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

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

Re: How I fell in love with Erlang

#40
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…

> 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 evange…

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.

Post reply on HN