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.
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!
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.
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.
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.
In any LLM it helps to use simple tricks to give it a few extra prompts like 'No blabbling' and 'Keep your code example simple and to the point without adding anything exrta' still but there's all sorts of research on optimization for getting better results from just how you frame your interaction with it in different and more exacting and concise wording:
Really a lot of stuff you'd find in any university/college English course for academic writing style for getting your point across clearly applies as well:
Personally though I've been avoiding its use in code and keeping it to where it shines. I've said this over and over. It's so good for writing drivel like copy and product descriptions and instagram posts and SEO-able text content. Stuff that people have been used to sounding kinda fake for decades if not over a century by now, that I have no heart to write myself but I can now literally just tell a robot to "increase engagement" and it shows in $$$.
Where I've found limits in what it can generate with code is with complex concurrency stuff that you really need to have knowledge about yourself to be able to prove isn't going to crash. The kind of stuff that you might pick up Elixr or Go for, specifically, I have always found it hits serious problems generating that kind of stuff. You need serious engineers who know stuff like TLA+, coq, spin etc to get that right if you're making systems that peoples lives or finances might depend on. I worry there's a lot of generated code being put out there in production which is not taking these things into consideration and people are just like 'wow it compiles, ship it'
It's still a good idea to look at an Erlang book like this one. Kind of like natural languages, it's handy to be able to read Erlang even if you don't or can't write it. There's a lot of older literature, Erlang, pre-Elixir, that is worthy of study.
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.
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.
That is using the Erlang array module directly from the Elixir REPL, including such fancy features as rebinding on the single variable name `my_array`.
The Erlang docs say this about the underlying data type:
"A functional, extendible array. The representation is not documented and is subject to change without notice. Notice that arrays cannot be directly compared for equality."
Based on my REPL test, at least when the element count is small, it looks like they're using tuples; specifically a tuple nested inside another tuple where the outer tuple is defining the array metadata.
I think the reason I've not used the Erlang module is that the Elixir Enum module (https://hexdocs.pm/elixir/Enum.html) is sufficient for the cases where I'd want some sort of indexed data structure. Typically though if I'm indexed I'm really after some sort of associative array and maps are sufficient for that case.
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.
Perhaps half the comments here mention Elixir. As of now, no comment mentions Gleam. I haven't used either, but been eyeing Gleam. According to GitHub stars (bad metric I know) Elixir isn't that much more popular than Gleam.
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?
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?
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 :)
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.
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!
For those familiar with BEAM-based languages, are there any advantages to choosing Erlang over Elixir when starting a new project?
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.
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.
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.
In any LLM it helps to use simple tricks to give it a few extra prompts like 'No blabbling' and 'Keep your code example simple and to the point without adding anything exrta' still but there's all sorts of research on optimization for getting better results from just how you frame your interaction with it in different and more exacting and concise wording:
https://github.com/jxzhangjhu/Awesome-LLM-Prompt-Optimizatio...
Really a lot of stuff you'd find in any university/college English course for academic writing style for getting your point across clearly applies as well:
https://alum.mit.edu/succinct-writing-guide
https://owl.purdue.edu/owl/general_writing/academic_writing/...
https://writingcenter.unc.edu/tips-and-tools/conciseness-han...
Personally though I've been avoiding its use in code and keeping it to where it shines. I've said this over and over. It's so good for writing drivel like copy and product descriptions and instagram posts and SEO-able text content. Stuff that people have been used to sounding kinda fake for decades if not over a century by now, that I have no heart to write myself but I can now literally just tell a robot to "increase engagement" and it shows in $$$.
Where I've found limits in what it can generate with code is with complex concurrency stuff that you really need to have knowledge about yourself to be able to prove isn't going to crash. The kind of stuff that you might pick up Elixr or Go for, specifically, I have always found it hits serious problems generating that kind of stuff. You need serious engineers who know stuff like TLA+, coq, spin etc to get that right if you're making systems that peoples lives or finances might depend on. I worry there's a lot of generated code being put out there in production which is not taking these things into consideration and people are just like 'wow it compiles, ship it'
It's still a good idea to look at an Erlang book like this one. Kind of like natural languages, it's handy to be able to read Erlang even if you don't or can't write it. There's a lot of older literature, Erlang, pre-Elixir, that is worthy of study.
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.
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.
> You are correct that Elixir doesn't have arrays and only lists... but that's also true of Erlang.
Erlang has the array module, which IIRC uses lists of tuples internally to simulate arrays. I assume that's what they are referring to.
Interesting. I didn't know about that module. But just like I asserted earlier... I don't need to write in Erlang to use that module:
That is using the Erlang array module directly from the Elixir REPL, including such fancy features as rebinding on the single variable name `my_array`.The Erlang docs say this about the underlying data type: "A functional, extendible array. The representation is not documented and is subject to change without notice. Notice that arrays cannot be directly compared for equality."
Based on my REPL test, at least when the element count is small, it looks like they're using tuples; specifically a tuple nested inside another tuple where the outer tuple is defining the array metadata.
I think the reason I've not used the Erlang module is that the Elixir Enum module (https://hexdocs.pm/elixir/Enum.html) is sufficient for the cases where I'd want some sort of indexed data structure. Typically though if I'm indexed I'm really after some sort of associative array and maps are sufficient for that case.
There are moments in which you will need to know Erlang to debug issues on an Elixir application.
Granted that for many Elixir devs, knowing (and learning) Erlang happens during such debugging efforts.
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.
Perhaps half the comments here mention Elixir. As of now, no comment mentions Gleam. I haven't used either, but been eyeing Gleam. According to GitHub stars (bad metric I know) Elixir isn't that much more popular than Gleam.
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?
Fly.io for Elixir is very popular
I have used Erlang when elixir still had to emerge. Today, I am using Elixir, with Phoenix LiveView and OTP Genserver, Supervisor and ETS.
I would start with Elixir, if only because of its newbie friendly community. The Erlang community is reflected in the 'erlang in anger' book.
But if you need to deploy on a small platform, say 32 bit 100MBytes, Erlang is the way to go.
Please know that both languages share a lot (the BEAM). Either will do to get to know the technology.
You can decompile bytecode to erlang .
This is how I learned Erlang and the BEAM back in the day, and I'd still recommend it.
(2015)
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?
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 :)
Huh I assumed this was based off The Little Lisper. I have no clue why in retrospect.