startup
Elixir has nicer syntax but what other benefits does it offer and are there any drawbacks?
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
I’m posting this in response to Jose’s recent tweet (Cr. link) :
People are sleeping on Elixir for a coding harness:
Hot-code swappi...
New
Hello,
I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
AcmeScript — Writing JS hooks as if I were still using Elixir
I’ve been having fun building a little something over the last few days: Ac...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
uranther
I don’t know of an exhaustive list of the benefits of Elixir over Erlang. Off hand, I know that it has far better handling of UTF-8 strings out of the box. It has improvements over OTP such as Agents and GenEvent, and it has metaprogramming/macros which is huge. Elixir has a better ecosystem of tools and will continue to add features that improve programmer productivity because that is a primary design goal, e.g. PR: Introduce calendar types.
alxndr
There’s a decent summary on the Elixir blog in the Extensibility section.
NobbZ
Comparing the languages as such, the only difference is in fact the syntax, since both target the same VM.
If you consider the Standardlibrary part of the language then Elixir stands out against Erlang very strong, since Elixir does abstract away some things you always need to be aware of when using Erlang. As an example, in Elixir you can handle quite a lot of different container types the same way through the
Enummodule, while in erlang you always need to be aware of the actual containertype.Also in Elixir the setup of GenServers and such is much easier due to its metaprogramming capabilities. Also as @uranther already has mentioned, there are currently no lightweight replacements for Agents and GenEvent, but one could build them from a GenServer.
I don’t consider the ecosystem of one language better than other. Now since rebar3 (Erlangs second most* popular buildtool) is very mature, erlangists are now able to share their libraries via hex. And like alchemists are able to use erlang packages, erlangists are also able to use Elixir packages. There are some limitations in both directions, but in general it is possible. So each language benefits from the ecosystem of the other.
AstonJ
For me some of the biggest benefits are:
All that is on top of the fact that Elixir runs on BEAM - making it a battle tested technology and perfect for the modern web.
Some might say Elixir is too good to be true
and making use of the ‘best’ of everything that’s out there shows that José is a very smart guy 
hilarycheng
I have tried both Erlang and Elixir. IMO,
Elixir has
riverrun
I’ve written more in Elixir than Erlang, but I enjoy using both.
For me, the main advantages of Elixir over Erlang are the tooling and the metaprogramming.
The tooling makes it so much to get started with Elixir, and the metaprogramming gives you real power to adapt the language to your needs.
jeffweiss
Elixir Benefits:
Erlang Benefits:
JEG2
Elixir in Action has a section on pretty much this exact question. In it @sasajuric explains the benefit of how much less boilerplate code there is in Elixir. On one level it’s built-in niceties like
GenServer, but Elixir goes further by giving you a rich macros system for layering on your own abstracts, like ExActor does. (This is a crude summary of the book. It goes into more details and covers other benefits.)rvirding
I had promised myself, and José, not to get into discussions like this but someone else has already thrown down the gauntlet.
So:
While you may prefer the elixir syntax, because it feels more comfortable or closer to what you are used the erlang syntax syntax, however you look at it, is simpler and more consistent.
I am an old lisper from way, way, way back so I fully understand the power of macros. And their problems as well. They are probably the best tool for writing code which is totally incomprehensible by others. So there is a very good reason that they were not included in erlang. Also if you want macros as god intended then you should use LFE.
I am ambivalent about avoiding boilerplate code. While it is nice not to have to write stuff the gain gets become small when you migrate from example code to real programs. Also even if you don’t see you have to know it is there so you can understand what is going on.
Also being explicit is good. It makes it easier for other people to see what you mean and what is happening. Hiding things is not good in the long run.
Let’s face it Agents are not really an abstraction you want to go with. I know clojure has them but they are really just global variables. With all the problems that you get with global variables. And they are implemented with gen_servers.
Yes, elixir tooling is better than erlang’s but with rebar3 we are catching up. Also I would say that tooling is more important in the beginning of a project, and with short projects, but becomes less important as time goes on.
Having binary strings is actually not that much of a benefit over lists, though it might feel more comfortable to use as other languages do it that way.
I have practically no knowledge about the web server side so I will take your word for it about phoenix being a good tool.
Etc, etc, etc …
It all boils down to which choices you make, what you feel is important and how you want to work. So while some choices made by elixir are the same as for erlang, otherwise it would not be implemented on top of erlang/otp, some choices are different. These are what makes the languages/systems different. As they quite happily coexist you are free to choose what you feel is important and go with that.
These are of course all my views, and I know many will not agree with me.
I will stop now or else I will never finish,
Robert
NobbZ
Depending on your needs, this can make a huge difference! Just remember, on a 32 bit machine a charlist of 100 letters length does need 100 * 4 bytes for the letters themself, 100 * 4 bytes for the pointer to the next char and another 4 bytes for
[]at the end of the list, so it is 804 byte for that 100 letters.A binary string does use 3 to 6 words of 4 byte + the data itself. So using my 100 letter string from above and assuming everything is ASCII we have a memory usage up to 124 bytes. Beeing totally unlucky and having to deal with characters which are all represented by 4 bytes in UTF-8, we had 424 bytes, just a little bit more than half of what we had with char lists.
On a 64 bit machine it were even 1608 bytes for char list vs. 448 bytes as binary string.
At least, this is how I do interpret the numbers given in the erlang efficiency guide, chapter 10.
But I have to admit, I am doing
But I feel it is much easier to transform a list of characters/single character substrings than the binary blob itself…
str |> to_char_listorstr |> graphemesvery often, and at least with the latter I probably make everything worse in terms of memory consumptionedit
Don’t get me wrong with this, I don’t want to favor one way over the other, but I want to make everyone sinsible about datatypes and use cases.
One of the things I have already told about memory downsides of character lists, there is also the random access problem, as well as others.