As someone who learns best by doing, what are some practical projects that someone could do to learn Elixir? I know that Elixir is quite capable of solving certain kinds of problems very elegantly, but maybe my experience hasn’t presented these kinds of problems yet. Outside of building a Discord-like server or a Phoenix web app, what other good practical projects/applications are there for Elixir?
- as a custom DHCP server to do multiple concurrent PXE booting (among other things)
- as a system for provisioning on-metal deployments (like ansible but less inscrutable).
- as a system for provisioning virtual machines over distributed datacenters.
I'll probably also wind up doing DNS and HTTP+websocket layer-7 load balancing too by the end of the year. Probably large-size (~> 1TB) broadband file transfer and maybe even object storage gateway by next year. I've rolled most of these things out to prod in just about year. I honestly can't imagine doing all of these things in Go, without a team of like 20.
Elixir sucks at:
- platform-dependent, like IOS, android, or like SDL games or something,
- number-crunchy, like a shoot em up, or HPC.
- something which requires mutable bitmaps (someone this past weekend brought up "minecraft server").
Actually even desktop might be okay, especially if you pair it up with electron.
> number-crunchy, like a shoot em up, or HPC.
> something which requires mutable bitmaps (someone this past weekend brought up "minecraft server")
One thing I'd like to see for the BEAM communities long term are well maintained libraries of NIFs[0] for high performance and possibly mutable data structures. Projects like rusterl[1] and the advances made on dirty schedulers make this more feasible than it used to be.
It would be cool to write all the high level components of a minecraft-esque game in Elixir, and drop down to rust when you need raw performance. Similar to the relationship between lua/c++ in some modern game engines
What are you using to store state? The distributed system itself? An external database? Hybrid approach?
Not in prod (personal project), I have a websocket-scraper on an aws free tier that's dropping data into a sqlite file, that I can transfer to my laptop for offline processing, so there are lots of interesting options.
In crude and probably wrong terms, AP concerns can be more easily pushed to the edge and CP concerns like to be centralized.
Edit: So as not to have the DB be the ‘core’ of the app?
I have seen lots of codebases in lots of languages do this type of task, but aside from maybe spark on the high end, i haven't see it done better.
The beauty of erlang is your code reads like synchronous code so it's easy to read/maintain, but it has all the power of the parallelism of async code.
I wrote one in Scala+Akka and the actor model is great. It's even better when the runtime supports preemption, like Elixer.
Don't ever want to build a web app? That's pretty much Elixir's sweet spot, IMO. You'll get great productivity, great scalability, performance that's better than popular interpreted languages and a code base that's easy to reason about.
You'll also be able to do a lot from within the VM instead of relying on external services.
It will never be as popular though.
And it's not like other languages stay stagnant. JS and TS, Java with green threads, C# with actor and LiveView like libraries.
I migrated the code base for my last startup from Node to Rails at the end of 2015, then from Rails to Phoenix at the beginning of 2016. Pretty much all of that Elixir + Phoenix 1.1 code is still fine today. There haven't been any breaking language changes and the most arduous part of upgrading Phoenix to the current version would be the front-end—replacing Brunch with Webpack and removing Bootstrap. Other than that it's just a few lines of code.
The Rails app is slightly more dated but still fairly trivial to update. Most of the gems still do things in the same way and there's generally a clear way to go. The JS app on the other hand, is a pretty depressing mess of broken dependencies and multiple libraries I was using have dramatically changed their APIs.
For me, productivity and ease of maintenance matter much more than popularity does when picking a tech stack.
Why migrate working code to a new language?
And to do it twice?
The second time was because I'd gotten it to where it was getting users but I couldn't afford the server costs (given that it was free to use and my users were largely in Vietnam and Thailand). I needed something that could scale much more cheaply.
If I'd had millions of dollars in the bank, I'd have just stuck with what I knew and added people and servers as necessary.
I guess it's worth literally showing your measurements. The Elixir macro system is a vast improvement over merl. When people try to make re-usable gen_servers in Erlang it often becomes a mess. gen_listener in the Kazoo project is a mess and very hard to understand. I'm confident that if Elixir had been around when it was first written and they had opted to use Elixir, it would be way more approachable for developers. Another example from the Kazoo project where Elixir would help would be the ability to provide default arguments in the argument body.
Elixir itself has been the genesis of several improvements and optimizations to the BEAM. These contributions came from core Elixir developers.
I don't think your comparison to coffeescript is fair at all.
Joe Armstrong himself was quoted as saying Elixir was some "good shit" (may he rest in peace. Super smart and super funny is a rare combination).
c++ added extensive new tools that the base language did not have
c++ did not get its engineering team hired off to work on something unrelated
c++ did not create problems by misunderstanding c designs and trying to change them
in these four ways, elixir and coffeescript are alike
.
> Joe Armstrong himself was quoted as saying Elixir was some "good shit"
Yeah, Joe also said that object orientation was a terrible mistake, and if you read his design principles, Elixir was swimming upstream of most of them
When Joe got asked about this, his answer was simple: "I just like to support other peoples' programming languages. You can tell my personal preferences by what languages I use."
.
> may he rest in peace.
I also miss Joe :(
> Yeah, Joe also said that object orientation was a terrible mistake, and if you read his design principles, Elixir was swimming upstream of most of them
Did you, by any chance, use Elixir in 2011 and never really re-approached it?
Back in 2011, Elixir was an attempt to bring Ruby and object-orientation to the Erlang VM. It had a prototype-based model, it had eval-based meta-programming, it had loops, and, as you may guess, it failed pretty spectacularly.
But at the end of 2011 and beginning of 2012, I started from scratch. Object-orientation has been removed, a Lisp-based meta-programming model was introduced, most Ruby influences were removed except for minor syntax constructs.
Saying that the design principles were "swimming upstream" of OO principles are inaccurate since 2012 - as most of your other comments in this thread. Our main additions at the language level, compared to Erlang, are macros and protocols, where one is Lisp-based and the other is taken after Clojure/Haskell. From 2012, putting the Erlang VM front and center has literally been one of our main design goals.
But everyone's entitled to their own opinion. I occasionally read opinions from polyglots who prefer Erlang's syntax to many other languages. But I personally much prefer Elixir's syntax to Erlang's. For one, the issues in dealing with strings and binaries as mentioned above, for another, I find the punctuation rules in Erlang to be a complete PITA ("." and ",", anyone?).
I suppose it's all opinion, but the points you make about Elixir, when it really is very similar to Erlang 'semantically' (not syntactically), are interesting for how at odds they seem with any of the expert Erlang and Elixir developers I've spoken to, or any of the better researched opinions I've read.
Which is why I find your posts interesting, if not a little misguided.
Still a very impressive use of elixir IMHO.
They haven't switched, just use Rust at some places for performance improvements.
Thanks for the correction. Unfortunately I cannot edit my original comment.