New to Elixir, what's the best way to learn it and how does it compare to other languages?

Hi there!

I work mainly in Javascript and Typescript at work, I have about 4 years of experience on these topics and I’m pretty comfortable

I’ve heard of Elixir and am in complete love with the way you handle things (competition etc)

I’m sorry the language isn’t more widely used in France, but I’ve got an idea for a company to set up and I’m banging on about using Phoenix.

I have several questions:

  • What do you think is the best roadmap for learning Elixir?
  • What’s missing from the Elixir ecosystem? Would you have any ideas for a bookstore, for example, to contribute to the ecosystem?
  • How would you compare the Elixir ecosystem to that of Java?
  • Is Elixir close enough to Scala? If you had to compare the two, what would you say?

Thanks in advance

4 Likes

I’d say this is a very good start: Introduction — Elixir v1.16.0

6 Likes

I’ve been very curious about this myself as some of the complaints I’ve heard from outsiders is that the ecosystem isn’t big enough. The only thing I’ve rolled myself in the past 3 years is a paddle (billing) library. A recent search on https://hex.pm/ yielded GitHub - imricardoramos/paddlex: An Elixir wrapper for the paddle.com API which was published around the same time I integrated with Paddle.

A big difference from the JS ecosystem is that there are 1-2 good libraries for each topic rather than 100. And those projects may appear “dead”, but they are actually “done”. Stability is a feature, so you don’t need to keep upgrading / breaking things.

For instance, the two most popular pooling libraries:

Poolboy has not been updated in 5 years, yet it just works. I’m using nimble_pool currently as it has different performance characteristics than poolboy, but both work fine.

I periodically browse Libraries - Elixir Programming Language Forum and find some gems. Recently, I came upon Pegasus - PEG grammar parser which has changed my relationship with Regex forever (thank you @ityonemo ).

Now, if you can’t find the thing you are looking for written in native Elixir, there are also the Erlang libraries. And if you can’t find anything in the Erlang libraries, you can also drop down and wrap Rust/C libraries. For instance, here’s an Image - an image processing library based upon Vix . And before I forget, you can also use rustler | Hex or zigler | Hex to incorporate Rust/Zig directly into your codebase.

Also, I’d be remiss if I don’t mention that mix is one of the best package management / build systems in any language.

Phew, that’s a lot of information. I’d be very curious to know if you can’t find what you need.

But there’s more because there are various ecosystems.

  • Phoenix is the most loved web framework. Liveview has inspired knockoff after knockoff. However, there’s no chance any language can actually compete with Liveview on performance as it is built on websockets and diffing the dom with only changes. If you want to actually get something out the door with a small team, there’s really no competition. You want to develop a SPA? It would be very difficult for a React team to out-iterate Liveview because there’s no front/back split. Are you all in on LiveView? How are you using it? - #2 by tj0 is a post of mine from two years ago and things have just gotten better.
  • Nerves is the cornerstone of the Elixir embedded/IOT space.
  • NX - provides the foundation for high performance compute. I used to be as a physicist and worked a great deal with HPC clusters. Elixir makes distribution trivial.
  • Elixir desktop is pretty nifty. I haven’t used it, but I have used Burrito to create single binaries for distribution. This is no-longer just a Golang convenience.

Formerly an architect of large systems, I worked with many teams across many languages. I must say that Java is consistently taking the best features from other languages and incorporating them. The language itself lends itself to mediocrity for some reason. The ecosystem is huge and you can find pretty much anything you want. However, I think teams of every other language move faster than Java. I actually developed a passionate distaste for frameworks and orm’s due to Java/Hibernate. My stance on ORM’s has changed since using Ecto, which is a completely composable ORM for Elixir that doesn’t get in the way. And, of course, Phoenix Liveview is the most loved web framework from developer surveys and also changed my perspective. There’s no magic. So, I’m not really sure what’s missing in the ecosystem myself, and all things being equal, Elixir is far more productive.

There’s far more to compare with JVM vs BEAM.

  • Elixir has a heap per process and can reap without affecting performance. I’ve had dealt with too many issues with JVM GC.
  • Raw numeric compute performance will go to JVM. Elixir does have NX, but that is specialized. (I believe this may have been a tradeoff when designing the language. Ericson needed uptime with hot-code reloading which means that dynamic typing would be more difficult which means numeric performance couldn’t be easily optimized. Could be completely wrong about this though.)
  • Libraries - both have enough. JVM has more enterprisey integrations. I doubt there is a SOAP integration library for Elixir.
  • Scaling - BEAM hands down. Of course, your project will probably not need to scale that much compared to Discord and Whatsapp.
  • Productivity - for the web space, I’m not sure what language can compete with Elixir over a 5 year project. Tough to say. Anyway, Elixir is fast enough in 2024.

I’ve written much more about performance here:

And you should probably listen to this talk for more information about BEAM.

“Elixir is a dynamic, functional language for building scalable and maintainable applications.” - from elixir-lang.org

For the non-newcomer, I would say this instead:

Elixir is:

  • functional in a very practical way. With purity with respect to functions and practicality with respect to side-effects. No need to know what a monad is.
  • dynamic - the strongest of the weakly typed languages and now becoming gradually typed. Note that there is also diaxylzer that supports making the language statically typed.
  • infix lisp2 - you know, it’s best just to read Wiki - ElixirForCynicalCurmudgeons about this. Really one of the best articles about a curmudgeon discovering elixir and ending up lauging maniacally. And I quote It’s all macros. It’s ALL MACROS! ALL THE WAY DOWN! AAAAAAAAAA AHAHAHAHAHHAHAAAA!". Yah, just go read it.
  • object-oriented - I shouldn’t write this, but if you consider Smalltalk OO, Joe Armstrong has said he thinks that Erlang is “possibly the only object-oriented language”
  • scalable - much has been written about BEAM. Whatsapp, Discord, and others use it for a reason.
  • maintainable - close to nothing has been written regarding maintainability of different software ecosystems.

Elixir and Erlang are extremely maintainable languages. BEAM systems will just keep working and are pretty safe to make changes for reasons that I cannot understand beyond the word “functional”.

Scala supports numerous language constructs and is extremely flexible, but this also makes it very difficult to maintain. Think of C++ or Perl. I’ve seen Scala projects falling apart after a few years due to this, even with the primary engineers present. Projects needing an extra 1 or 2 quarters to get into production with the reasoning, “Well, this wasn’t built the ‘right’ way, so now we have to do x-y-z to get it to work.”

My favorite exchange of all time:

He was a good friend, so the best part of that story was that I got to razz him about that exchange for a few years. :rofl: It has happened to me as well. I’ve written projects in Perl and when someone asked for changes, my response ridiculously enough was, “You know, I have no idea how to modify what I wrote, it might be faster to re-write it.”

Also, regarding Scala, I remember vaguely that it was extremely difficult to get things to build, but when they would build, they would work. Ecosystem has probably evolved from that point.

So anyway, you can do anything you want with Scala (quite literally). However, due to long-term maintainability concerns, unless you have something very specific that you can only find in the Java ecosystem, I would pick Elixir for maintainability alone.

Elixir/Erlang have failures in the MBA/Management arena, where they always get questioned regarding ecosystem and hiring, but anything that gets built just keeps running and outperforms all the rewrites. But that shouldn’t matter for you as you’re trying to do your own thing.

Anyway, I’ve channelled my inner @dimitarvp to write this long. :grinning:

Speaking of community, I’m not sure about the Scala - aka - somewhere you can ask questions, but I find the Elixir community very helpful and nice.

Also, in my completely biased opinion, Elixir is the greatest language ever made and you’d be utterly insane to pick anything else. :rofl:

Without excessive hyperbole, I’ve been involved with projects with many languages and frameworks, but now Elixir is my goto language for almost any project. When I have to use another language, I’m always wondering why I’m doing this and question my life choices. It’s just extremely tough to beat the combination of productivity and cutting-edge technology coupled with incredible reliability, stability, and maintainability.

Give it a try and welcome to the community.

2 Likes

Oh well, we all got a reputation. :grimacing:

1 Like

Nitpick - there are a handful, if you count Erlang implementations:

Or you could always use a JVM library and make a Java node

1 Like