Learn You Some Erlang for Great Good (2013)
17 comments
·March 16, 2025jasonthorsness
What are the modern hosting platforms for distributed BEAM apps? The language model seems perfect for some kind of global distributed app, but can you leverage a network already built sort of like how Cloudflare workers or Vercel edge functions work?
AlphaWeaver
This book is a fantastic introduction to Erlang in very approachable language. It introduces the reader to both language syntax and design decisions that led to Erlang's strengths as a highly reliable programming language for realtime applications.
If you're learning Elixir right now, I can't recommend enough to also learn a bit about Erlang. The OTP and BEAM VM sit underneath both systems, and learning about what's going on under the hood helps a ton when troubleshooting production issues!
bikingbismuth
Though my Erlang skills have long atrophied, this book was my intro to functional programming and helped me understand recursion. It’s been a while since I’ve read it but I remember it being kind of funny as well as informative.
8s2ngy
For those familiar with BEAM-based languages, are there any advantages to choosing Erlang over Elixir when starting a new project?
joisig
I've used both heavily and I'd have to say no. You are in general better off with Elixir, with easy access to all Erlang and Elixir libraries, all BEAM functionality, a better package manager and build tool, and a more modern feeling / easier to learn programming language. Also starting to see a progressive type system and just a much faster developing ecosystem in general.
I think by now there's also more open source Elixir code out there, which means LLMs will be somewhat more proficient in Elixir (they're not great at it though, but enough to help).
It's harder to work in Erlang and incorporate Elixir libraries than the reverse, although it's certainly possible (you would use the mix build tool from Elixir to do so).
My main pros for Erlang are that it's a simpler language than Elixir with less "magic" and fewer footguns. I still use both, in the same system even, but most new code in the system is written in Elixir.
jamal-kumar
Oh boy. One of the things I have been doing to test if an LLM is 'there yet' by my standards is if it can spit out solutions in elixir without hallucinating packages that don't exist to get the job done. Since I haven't tested since chatgpt 4 came out I dunno where it's at for that but always felt like a decent litmus test.
sbuttgereit
I find that Claude 3.5 does a very admirable job. I only rarely see incorrect code and more frequently see recommendations for older libraries or obsolete versions of real libraries as compared to hallucinated libraries.
I've been playing with Claude 3.7 thinking and, perhaps unsurprisingly, I find it overthinks the problem or tries to do far more than I really want it to for any prompt. I expect that I'm just using the wrong tool, and probably should just use Claude 3.7.
Of course in all of this, I'm using the LLM in a "junior" capacity and I'm not giving it giant multi-faceted problems to solve: I'm giving it relatively narrow problems to solve at any one time and am guiding it through that process.
nikhizzle
I’m not sure there is a huge advantage at the beginning, perhaps even a disadvantage because of the ease of use of Elixir. As you get more advanced you start using Erlang here and there to access things not in Elixir. For example, Elixir only has lists not arrays, so if you need a good indexed data structure you end up using some Erlang. Also once you start getting into Mnesia etc, Erlang is the way. All this said, still very early on my Erlang journey.
sbuttgereit
I guess this depends on what you mean by "end up using some Erlang".
If you mean that you end up calling certain library functions and such which are written in Erlang from Elixir.... well, yes, and you need to by design.
But I'd argue calling a function written in Erlang or from Erlang's standard libraries isn't the same as having to write Erlang code. I use Erlang's ETS, its in-memory key-value store, quite a lot from Elixir. I'm calling the Erlang ETS functions, but I'm not writing Erlang code I'm writing Elixir code which simply calls the Erlang functions. To me that isn't the same.... which for me is probably good: I know enough about Erlang to read the docs and to read Erlang code well enough by now... but not to write it; I've been writing Elixir code for years now and never had to write actual Erlang to accomplish anything. The closest would be a matchspec (kind of a matching DSL used by certain built-in Erlang databases), but I don't consider that writing Erlang, but more DSL like. I've also used Mnesia from Elixir in the same fashion: I call the Erlang libraries which are Mnesia, but I'm not writing Erlang code to do it: I'm writing Elixir code which calls Erlang libraries.
I'd disagree with the larger statement where you say, "Elixir only has lists not arrays, so if you need a good indexed data structure you end up using some Erlang." You are correct that Elixir doesn't have arrays and only lists... but that's also true of Erlang. Elixir and Erlang basically share the same primitive data types. I have to assume by "a good indexed data structure" you are referring to the previously discussed ETS which is more a K/V store than something like a data or data structure. Otherwise, you'd have to be more specific to what you are referring.
I think it's true that if you are going to write any serious amount of Elixir, you will benefit greatly from having some familiarity of Erlang. Not because you're necessarily going to write Erlang, but because Elixir was designed to be very compatible with Erlang's approaches, philosophies, and, most importantly, Erlang's runtime the BEAM. Because we do use Erlang library calls we will read Erlang documentation, frequently. We will see examples of those libraries written in Erlang, errors coming from the Erlang side, etc. None of this is to say I have to "write Erlang" to do any of this, but familiarity with Erlang doesn't hurt at all.
In the end, Elixir is simply a more expressive way to address certain kinds of problems while still reaping the benefits of Erlang and its VM, the BEAM. If you don't leave the kinds of problems to which Elixir is well suited, you will certainly encounter Erlang's standard libraries and benefit from being able to read Erlang and its documentation... but you won't really have to write it, just call its libraries.
29athrowaway
There are moments in which you will need to know Erlang to debug issues on an Elixir application.
tenk4
This book is nothing like the famous Haskell book of similar title. It's really hard to read, with walls of text displayed in a very small font and very little contrast. And already in the first pages it fails to explain the basic question for the newcomer: Why do I need Erlang? What can it do that other languages can't?
ollien
I haven't read the Haskell version (or at least, not more than a small portion and in a long time), so I can't comment on the comparison, but what did you find insufficient about the "So what's Erlang?" section? I think it explains the benefits quite well, though I am someone who writes BEAM code for a living :)
ForTheKidz
Huh I assumed this was based off The Little Lisper. I have no clue why in retrospect.
joisig
This is how I learned Erlang and the BEAM back in the day, and I'd still recommend it.
This book is very clearly a labor of love. He put so much work into it, much more than would have been necessary to just create a simple book about Erlang.
It's very well done and if you're at all interested in Erlang, is worth purchasing.