Live data from Hacker News

How I fell in love with Erlang

boragonul.com

211–220 of 263 posts

Re: How I fell in love with Erlang

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

For me (and I've been writing Elixir for probably a decade now...) Joe Armstrong's post here encapsulates it pretty well: https://joearms.github.io/published/2013-11-21-My-favorite-e...

And for me, what it comes down to, is, doing powerful things in Erlang/Elixir is trivial where it would be really convoluted in other languages. When applied to the right problem, it genuinely makes a whole class of problems evaporate, and that's addicting.

Re: How I fell in love with Erlang

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

Pattern matching and function guards sold me. I'll never look back, you can take patterns out of my COLD DEAD HANDS!

Re: How I fell in love with Erlang

#214
post #81

If you like Erlang, I recommend reading Making Reliable Distributed Systems in the Presence of Software Errors by Joe Armstrong: https://erlang.org/download/armstrong_thesis_2003.pdf His PhD thesis explains the thinking behind Erlang, especially how it handles failures, message passing, and concurrency. It was last updated in 2003, 22 years ago, time really flies!

Thank you for this, I'm unlikely to ever touch Erlang but looks like a fascinating read nonetheless.

Re: How I fell in love with Erlang

#215
post #125

Earlier quoted context omitted.

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?

The one that I can share is at: https://github.com/MuseSystems/musebms

A few things to keep in mind. This is a "labor of love" personal project... sure a large one... but that's what it is. Another thing to consider is that I go off standard Elixir practices in a number of different ways and for reasons™; in this sense the project isn't representative of what a typical Elixir project looks like.

When I say that things take longer for me to initially code, I'm not including "self-inflicted" time dealing with novel issues which arise from taking a less common path... which does have its own time cost. In my previous comment I'm only really thinking of the typical aspects of Elixir development time.

Finally, I do need to emphasize: for me the cost is worth it. Once I get to maintaining that now-developed code or doing refactors, so long as I'm not throwing away everything and starting from scratch, the development time for me is rather less than I have with code of similar complexity developed in other languages. All personal experience... but there you have it.

Re: How I fell in love with Erlang

#216
post #187

Earlier quoted context omitted.

You certainly can forget to push fixes to the source repo. But if you do that enough times, it's not hard to build tools to help you detect it. You can get enough information out of loaded modules to figure out if they match what's supposed to be there. I had thought there was a way to get the currently loaded object code for a module, but code:get_object_code/1 looks like it pulls from the filesystem. I would think…

You can run https://www.erlang.org/doc/apps/kernel/code.html#modified_mo... in some process and make it send notifications to your monitoring when anything stays modified for too long.

That's part of it yeah. But, at least in my experience, that tells me you pushed code (to disk) and didn't load it. You could probably just notify at 4 am every day if erlang:modified_modules() /= []; assuming you don't typically do operations overnight. No big deal if you're doing emergency fixes at 4 am, you'll get an extra notification, but you're probably knee deep in notifications, what's one more per node?

But, that's not enough to tell you that the code on disk doesn't match what it's supposed to be. You'd need to have some infrastructure that keeps track of that too. But if you package your code, your package system probably has a check, which you can probably also run at 4 am.

Re: How I fell in love with Erlang

#217

Took me a long time to figure out what gets lost with Erlang is: a) Ubiquity — everything understands HTTP. Erlang nodes only talk to Erlang (or a compatible runtime) b) Because there are no middleware standards (REST, GraphQL, OAuth, etc.), you must build or integrate your own abstractions c) Giving up infrastructure (reverse proxies, load balancers, CDNs), You handle distribution yourself or through OTP design d) I…

There's probably not as much advantage to HTTP as you think.

The simplest RPC protocol is where you connect to a TCP socket, send a newline-terminated string per request, and get a similar response back. You don't need HTTP for that - you might still want to use JSON. What does HTTP give you in addition?

It's presumably still not something Erlang directly supports.

Re: How I fell in love with Erlang

#218
post #204

Earlier quoted context omitted.

This stands to reason. If you need to bridge different languages together like in your case, they need to speak a common tongue. REST/GrahQL/gRPC solve this problem in different ways. There is no technical limitation keeping you from serving HTTP traffic from Erlang/Elixir, but from my own experience it isn't a pleasant experience. JavaScript or Python are dead simple, until you realise that 64-bit integers are not a…

> There is no technical limitation keeping you from serving HTTP traffic from Erlang/Elixir, but from my own experience it isn't a pleasant experience. I would be interested in what was unpleasant? I've run inets httpd servers (which I did feel maybe exposed too much functionality), and yaws servers and yaws seems just fine. maybe yaws_api is a bit funky, too. I don't know the status of ACME integration, which I gues…

Perhaps I was a little harsh, this was a few years back when I was evaluating Elixir for a client, but ended up going back to a TS/Node.js stack instead. While the Phoenix documentation is stellar, I found it difficult to find good resources on best practices. I was probably doing something stupid and ran into internal and difficult to understand exceptions being raised on the Erlang side, from Cowboy if I recall. In another case, I was trying to validate API JSON input, the advice I got was to use Ecto (which I never really groked) or pattern match and fail. In JS, libraries like Zod and Valibot are a dream to work with.

The result was a lot of frustration, having been thoroughly impressed by Elixir and Phoenix in the past, knowing that I already knew how to achieve the same goal with Node.js with less code and would be able to justify the choice to a client. It didn't quite feel "there" to pick up and deploy, whereas SvelteKit with tRPC felt very enabling at the time and was easily picked up by others. Perhaps I need another project to try it out again and convince me otherwise. Funnily enough, a year later I replaced a problematic Node.js sever with Phoenix + Nerves running on a RPi Zero (ARM), flawless cross-compilation and deployment.

> Ports are not network transparent

I stand corrected, thank you for the explanation!

Re: How I fell in love with Erlang

#219

Earlier quoted context omitted.

This blocked me from understanding computer programming for 3 years. I thought of 'variables' as immutable and the fact that they were not didn't really click at all. Once I mentally transitioned from 'it's a label attached to a value' to 'it's a named box which holds a value' life got a lot easier. I was 15 when it finally clicked (on a TI programmable calculator...).

I wonder if haskell would have made more sense to you at the time with everything being immutable.

The answer to that is surprisingly simple: no. Because Haskell didn't exist at the time. Neither did Erlang. But LISP did, but was just too expensive and memory hungry for mere mortals such as me. I had to learn all this on a shoestring budget working an 8 hour job and barely having left over enough money for food after rent, taxes and insurance. It took a long time before I was able to afford a floppy drive, much less a half decent computer, one that would be able to run LISP. And those language packs weren't cheap either and open source wasn't really a thing yet (but shareware actually was).

Re: How I fell in love with Erlang

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

It’s not really such a different meaning, it’s just shorthand for something like:

    X’ = X + 1
    DELETE X
    X = X’
Even if you treat it as “storing a value in a slot”, a comprehensive model of the operation needs to model the fact that the value of the slot changes over time. So another way to look at it would be:

    X_t1 = X_t0 + 1
…except that “X” is shorthand for “the latest binding that uses this name.”
Post reply on HN