Why am I still excited about Elixir?2020-01-20
A good ol' while back I wrote about why I'm interested in Elixir. I think that deserves some follow-up.
So what's different? Well, I've worked a lot more with Elixir in a professional capacity since then. I've built more things in it both for work and play. I've also gone digging and written about it in weird and extensive ways that I hadn't expected.
Professional work in Elixir
I started working with a client that needed work done on an existing Elixir backend. They needed to add an entirely new API to an existing solution. When I encountered the backend I was warned that it might be a bit messy. I agree that it had the signs of a system that had been through some startup-intensity development. I had concerns approaching it but its been fine.
What surprised me was how quickly I could get familiar with and understand the code. I'm pretty used to picking up a new system. But I think the fact that there aren't any complex class structures and that state is so isolated by of immutability reduced the cognitive effort of getting productive in the code-base. I could focus my brain on the business end of what I was doing.
Product development in Phoenix
I have a product that is still internal to my company that is being developed as a Phoenix backend which has so far been a fairly smooth ride. The biggest gotchas have been the aforementioned deep dive into Ecto and some things like CloudFront Signing. When I encounter these edges that I end up spending time on I tend to write about them these days. I find it makes me push my understanding of what I'm doing further and I'm a lot more likely to be able to find the solution next time I go looking.
Lots of learning, lots of hands-on experience with what architecting in Phoenix will mean for you. It has been good overall. A lot of CRUD which is a bit dull but also some interesting cloud integration which mostly makes me dislike the AWS UI more and more.
I think my biggest take-away in both product work and client projects has been that I really quite like working with ExUnit. Testing Elixir-code feels straight-forward. It feels like the easiest way to verify whether I wrote the right code or not. I barely feel the need to run the code outside of tests.
Automated complaints: Credo & Dialyzer
I've started working with both Dialyzer (mostly through the Elixir LS Fork + VS Code) and Credo which both help keep me honest and catching mistakes, messy code, opportunities for refactor and a lot more.
So Credo checks your code according to a bunch of best-practice principles. You can customize it, but I've been fine with the defaults.
Dialyzer performs analysis, mostly through type inference if I've understood it correctly to point out things like logically dead codepaths in your programs and such. Any time I've had Dialyzer complain, there has been an issue. Often not an issue that would cause an actual problem, but still incorrect code.
Nerves & Raspberry Pi 4
The Pi 4 was released and Nerves supports it. It differs a lot from previous models. Its pretty cool hardware for the cost. I recommend trying it out. The most tried and true hobbyist hardware for Nerves is still the Pi 3, especially for Scenic. That's bound to shift over time. Anyway, the Pi 4 opens up more heavy-duty options within the same form-factor.
The Lumen Project
This one I have to dive deeper into soon. The grand promise of this project can be put quite succinctly.
Elixir in the Browser.
The details are more complex and a lot cooler. I know there have been projects for bringing Python to the browser which do so by providing a big compiled Python interpreter as JS download. I haven't looked into what ground has been won there with WebAssembly but I hope its significant. What Lumen is doing seems more ambitious to me.
Lumen and the related Eir project fills in some important gaps to get from an Elixir or Erlang application to compiling to WebAssembly through LLVM. Lumen is not a WebAssembly implementation of the Beam VM. It changes the approach to be potentially more lightweight by only compiling in the actually used parts of the runtime, compiling it all to a WebAssembly binary and integrating it with the browser.
The team has stated that they will follow the existing BEAM VM as their living standard for what Lumen should do and maintain as much compatibility as possible. They are dropping some features of the BEAM to win some web-friendly optimizations. Hot code swapping is removed to allow removing unused code for example.
There are examples, you can run them now. You can run* Elixir** in your browser. Right now.
The ambition of Dockyard in doing this is exciting. They basically want to minimize the amount of JS they have to write and I think this approach might be feasible in the longer term. I really hope this can provide another option to the JS ecosystem. I find it workable but I don't particularly enjoy it.
Even if you don't believe in the idea I recommend watching their presentation from ElixirConf because I found it absolutely fascinating.
* There are still many limitations. You will likely only get running with the existing examples.
** Well, parts of the language. It is not entirely implemented, as not all of Erlang's BIFs are implemented yet.
The Elixir Forum
As I've been working rather than spending as much time chatting on the Elixir Slack I've found myself looking at more asynchronous communication channels and I've been visiting the Elixir Forum more and more. It is a well-run community that I've found rewarding to engage with. Very enjoyable. The Slack remains good as well.
Any bad stuff?
Not really, nothing in particular. I haven't seen any bad parts that feel particular to Elixir and friends. Maybe some vague Erlang errors messages. Oh, and I don't like reading the type spec stuff that comes out of dialyzer. Or writing them honestly. But it ain't terrible.
I haven't been able to pour the time I'd want into doing more Nerves stuff so I still find some of the driver and buildroot stuff impenetrable. I also haven't had much time for Scenic and I have some stuff I'd really want to build that relates to both of these projects. So yeah, bad stuff, I don't have time for all the things that I want to do. If another language can offer me this, let me know.
When I wrote about being interested in Elixir it was an ecosystem and community full of promise in my eyes. I had not spent much time doing serious work with it yet.
So far Elixir, Erlang/OTP and the BEAM have been delivering on what I hoped from them as tools. I'm still delighted to work with it on a day-to-day basis. I enjoy it more than I even expected to and there is so much more to get properly familiar with.
I find it easy to write, easy to read, easy to test and easy to reason about overall. It seems stupidly simple and provides a lot of elegance when you start getting fancy. I am every bit as excited about working with this tech going forward. I dare say
If you have thoughts, questions or want to get started with Elixir, let me know at firstname.lastname@example.org. Consider signing up for my newsletter down below if you want more of my writing along with my favorite podcast recommendations.