I’ve been writing in Elixir for some time now and sincerely if given the choice I won’t write in anything else than Elixir (or Erlang), mostly because of the Erlang programming model. I do write quite a bit of JS as well (mostly w/ Vue) but sincerely, I do it because I can’t write Elixir for it, otherwise I would. I also wrote Ruby for some time, and used Salesforce’s Apex (which is basically Java), and again, I much prefer to write in Elixir.
I think Elixir does a great job in cutting down the initial complexity of understanding the process model by giving you a syntax that is more “current” (hence familiar if you don’t have decades of experience) and allowing you to slowly shift from a normal sequential like programming model to a more process oriented one. It also has the benefit of hindsight, so it packs a much more, lets say, normalised stdlib/base lib, where things are grouped in a more logical way. You can mostly write an Elixir app with Phoenix and Ecto as, say, if you were using Ruby on Rails. You’ll be using the process model underneath it even if you never write those parts yourself and don’t see them in your code. But then you start seeing/reading/using other bits, that are really unique to the BEAM. Even in those, Elixir does a good job of making their initial usage more “accessible”, by only requiring you the minimum to try them (say GenServers for instance not requiring all the callbacks, etc), or providing some useful abstractions, like Tasks and Agents, that do not require you to be totally familiar with the process-receive-loop and monitoring and linking semantics.
This on the other hand has the drawback that you might not fully grasp what these constructs are doing, but I think it works well as a step from “totally linear sequential code” to “process oriented code”, which is probably the most difficult transition (even more than OOP to FP), in terms of concepts. Once you start using processes you might be interested in understanding how it actually works underneath in terms of BEAM.
I bought Programming Erlang 2/3 weeks ago and I’m enjoying going through it (about 45% in), because Joe focus on using basically raw processes (spawn & direct messaging & receive blocks), which in turn makes you understand why the concept of links, monitors, supervisors, gen_*, calls/casts, timeouts, OTP etc exist and are needed/useful in the language. You can understand those without going through Erlang, but going through it in this fashion certainly drives the point home very easily.
In terms of syntax they’re actually very close (I mean the way you write it while making it looking good), but Erlang forces you much more into it due to a more strict syntax, but I find them to look quite equivalent (like say Spanish & Portuguese, if you understand one, and you’re given a text on the other you’ll be able to understand what is being said).
Now for bike shedding, I prefer elixir’s atom conventions (:
), even though it’s a bit more ambiguous (nil/false/true don’t have the preceding :
) while in erlang those are atoms and none have :
indicating they’re atoms - on the other hand, in Erlang false & true have special meanings but they aren’t signaled in any way - so it’s also ambiguous. I also prefer writing var bindings with lower case, although I prefer that erlang enforces “no-rebinding” in written code. I’m not sure about the do
blocks versus ->
comma, semi-colon, period. I like pipe’s in elixir, and I think the String/Binary/Chr List handling is more intuitive in Elixir as well, although I can understand the benefits of “forcing” you to treat everything as <<binaries>>
to allow easy message passing inside the program and to the outside (sockets, etc).
I haven’t gotten to releases yet - and Elixir is gaining direct support for them in the close future - so not sure about that part. I think elixir is more “tailored” to allow easy development of working web-apps, easy on-boarding and access to the BEAM (&Erlang) goodies, more aligned to current dev expectations. It also has meta-programming, which is also, sincerely, neat, you can do a lot without even touching macros. On the other hand Erlang is the underlying language so learning it can only help in using Elixir (if for nothing else, just because you can call “any” Erlang code directly, it basically will extend what you can do with Elixir).
It’s also worth noting that things such as Ecto do go a long way if you are used to using Postgres with an ORM, the documentation is also more “accessible” and really shines (Erlang’s documentation is quite complete too, it’s just more “technical”, and let’s say, scattered). To finish - I haven’t gone through the whole book yet, perhaps in the end I will prefer to start writing everything in Erlang, who knows, I’m enjoying it nonetheless - but I think that, really, the process model & BEAM is what’s more important.