You and Elixir in 2021/22/23

Wanted to make a very slow Ruby on Rails reporting system faster. I already started learning Elixir some months ago and looked for an opportunity to utilize it in real business context. I eventually reduced those Ruby on Rails reports times from 3.5-4.0h to 5-8 minutes. It was a huge success!

Elixir did very naturally fit into such an ETL-like data processing pipeline. I respect it ever since.

C/C++, Java, Ruby, PHP, JS, Golang. Then Elixir and then Rust. I am only sticking to these two lately.

The language and the basic tooling themselves are absolutely excellent. There aren’t many drawbacks to find.

I believe the next phase for Elixir would be to commoditize parts of web dev in general – like having a tool actually analyzing and “understanding” your Phoenix code and allowing you to seamlessly move it around (which goes beyond simple refactorings). That might prove to be impossible however.

Erlang’s BEAM lends itself excellently to anything that needs to work in parallel. Even fantastic languages with dead-serious hardcore (and experienced!) fanbase like Rust still can’t catch up to OTP’s guarantees. They are inching closer, though!

If your project is NOT a CLI program or any sort of a server that needs every last bit of CPU power per watt – then it is very likely good fit for Elixir. We live in a world where CPU cores increase and CPU frequency hasn’t moved for a long time and likely will not anytime soon. Use technologies that utilize all CPU cores.

To me that’s Elixir’s strongest benefit. Its fantastic meta-programming is a close second.

Piping is both easy and makes code readable. Love it, always will.

Reducing compilation times has been a challenge. Analyzing dependency graphs has been getting easier (with Elixir 1.11) but I’d appreciate seeing a tool that can give you direct and immediate insights: “module X seems to depends on 100+ files, extracting this function to another module will help”. A note for future improvement.

Dialyzer and typespecs remain pain in the rear to this day. But I don’t think that will ever change. It’s more likely that Facebook will make statically typed Erlang, or languages like Caramel and Gleam will gain prominence (they are statically typed as well). I don’t think Erlang’s legacy tooling can be expected to change at this point.

More commoditization of, well, anything.

  • CLI tools with which you can directly add / remove all needed bits of code for a new functionality in your REST / GraphQL app; you’ll only have to write 10-50 lines of business logic and all plumbing is handled for you.
  • Mentioned above: insights about improving compile times.
  • A compat package that makes sure that all Elixir projects can use upcoming API like e.g. Enum.product (coming in Elixir 1.12) even if they are at Elixir 1.6 at the moment.

I am sure I am forgetting at least 5 more but hey, can’t keep them in my head all the time.

I could answer the other questions but this comment is too long already.

5 Likes

Never have heard of it:

It seems to compile to pure Erlang code, isn’t that a disadvantage when compared how Elixir and Gleam do it?

Oh, and that syntax with in in the end and full of if else :frowning:

1 Like

I admit I haven’t dug in the deals. I got attracted by the promise of strong and static typing at the compile stage, and the OCaml syntax.

I seriously have no time for such nice little distractions though… :frowning:

OCaml is recursive; in means that you are nesting this statement into the next one – otherwise the next statement won’t have access to variables declared in the previous one(s). It’s quirky, I admit.

if / else can be replaced by pattern-matching, at least in the pure OCaml (not sure about Caramel).

2 Likes

This bit really puts me off of even wanting to try the language, despite the strong typing promise, that I want so much in Elixir.

1 Like

My understanding is that you will also able to use Facebook’s ReasonML syntax (https://reasonml.github.io) with Caramel because it’s just a different syntax for OCaml.

1 Like

Me and Elixir in 2021:

I had an App’s idea which could be successful in a month (that’s what I thought then). Languages I already knew seemed insufficient for that app. :smile:
After reading different blog posts, watching talks etc, I came to the conclusion that Go or Elixir will be a perfect fit for that app. I started learning both of these languages.

Elixir made me a better programmer. I can’t explain how exactly, but it surely did.

Things I liked about Elixir when I got into it, were the pipe operator, pattern matching, function clauses, function overloading, and its familiar syntax. Then I realized that its real beauty lies in its concurrency model and the OTP.

I think Elixir is enough in all the aspects for the job it’s doing, but of course I’d like to see performance improvements, and luckily and thankfully there is a lot going on in that area already.

Don’t start leaning Phoenix before you’ve learnt enough Elixir, like you did when you were learning Ruby and Rails.

4 Likes

I am a java developer at work but I have dipped my toes in the elixir waters and find it fashinating.
I don’t have that much experience yet with the language since I work full time with my day job and have tree small kids.
But I have a small side project that I would like to build with elixir, phoenix and live view.

4 Likes

What first drew you to it (how long ago!?) and what keeps you here?

I started looking at Elixir when it was <0.10, back in 2013. The first commits I can find are titled “Fix deprecations in Elixir 0.10”. :grin: I was actually looking at Erlang first because I wanted to learn a functional programming language and I was interested in distributed systems. An IRC acquaintance suggested Elixir and I was instantly interested. I have to admit syntax was a big part of that.

How have you found it has changed over the years?

No more lc, records were deprecated, maps got power and structs appeared, got rid of multiple competing datetime datatypes, the standard library datetime functionality is very featureful now, Hex.pm appeared, ElixirLS appeared, and all around the tooling improved so much. Also we finally have blessed releases and runtime configuration! :tada:

The community has grown from an IRC channel to Slack, Discord, Matrix, and this awesome forum.

How have you changed, perhaps while using it? (Maybe you came from an OOP language and your mental model on how to build things has changed?)

Elixir was my first functional programming language and it shows in my early code. The most immediate impact I noticed was that I grokked map/reduce and their power. I started using them in OO languages too, and I think it has really improved me. I started splitting code into smaller, easily testable units, with less dependencies on object state. I nowadays have a healthier balance and can appreaciate aspects of both styles. Though I wish every language had immutability.

What do you think were the biggest strengths of Elixir/Erlang when you got into it and what do you think are its biggest strengths now?

It was BEAM for humans. No offense to Erlang, but back then it wasn’t inviting and the tooling wasn’t there. Nowadays Erlang has improved a lot and in general it feels like the BEAM community has exploded in both variety and quality of tooling.

I think BEAM is the biggest strength. What the VM offers is hard to find in other languages and there’s not many things that I find it lacking in, at least those that would touch me. In other words for me there’s no tradeoff to be made. Except the smaller size of the community when you compare to the giants.

Is there anything you’d like to see more of or improved or included?

Removal of charlist single quote syntax and pretty printing. Replacement of kwlists with maps in most function arguments. Typing! Very excited about Gleam/Caramel, though I haven’t tried them yet (there’s only so much free time).

Which bits do you love the most and which bits are you most likely to tell others about?

BEAM BEAM BEAM. The high quality stdlib, especially the string and datetime handling. Effortless concurrency that is used for things like Phoenix Channels. It’s like an OS for my project where I can start programs that talk to each other.

Also Nerves, Nerves is seriously awesome.

What’s your single most important tip to newbies?

Join the community chats, we’re quite friendly and really try to help you in your projects.

Which book or learning resource has been your favourite to date? (How many have you read? Which ones have been your favourite!?)

Metaprogramming Elixir made me finally understand macros. I have Elixir in Action but to my great shame I haven’t read it yet, though I hear great things of it. In general I’m not a reading person, I just hop in and mash code with the help of the API docs.

Hanging around on the different help channels and this forum makes you learn a lot of different things over time. I’m really grateful to all the good people helping others.

5 Likes

A small, likely unrelated tidbit: while I was still coding both in Ruby and Elixir back in 2016, I’ve made a habit of using Ruby’s object.freeze method to reduce my potential bugs area. IIRC any attempt to modify a frozen object results in an exception, making it times easier to track down code that attempts to introduce invalid state.

Same for me. The runtime itself is the biggest asset. Everything else is a nice bonus and just sealed the deal for me after the first few months with Elixir. To me the other huge strengths are the mix tool and the property testing library stream_data. And macros!

Well, let’s become friends because we are apparently brothers already. :037:

2 Likes

Yeah, after using Elixir for a while, I started using Object.freeze in JavaScript projects. For example when we retrieved anything from an API, we’d freeze the data before passing it to any frontend logic. This helped find accidental mutation bugs in the code. But it was a bunch of manual work.

1 Like

Agreed, but it pays off.

1 Like

TLDR;

  • What brought you to it? (Was there a specific article, talk or person that prompted you?)

I’ve tried Elixir many years ago after learning about it from the author of The Little Elixir & OTP Guidebook. I built a simple proof of concept distributed scraper and that was it. It was interesting but very nascent at that point of time. It was also hard to find jobs for it, at least at where I’m from, Singapore.

  • Which language did you come from?

Ruby!

  • How are you finding it?

Interesting, but getting used to the functional syntax is a little tiring

  • How do you think you’ll use it?

I’m intending to use it as my default stack for all my side hustles.

  • Which bits are you finding easy, which, not so much?

The functional way of doing things is a little tricky to me as I came from a Ruby (OO) background.

  • Is there anything missing that you’d like to see included?

Not for now~

2 Likes

After using it heavily for the past couple years, I’m considering moving on to another stack.

I think my frustrations with documentation and examples are just reaching a point where I want something that doesn’t seem to require such a constant fight to move forward. I love the idea of the BEAM, but the cost/benefit is beginning to weigh on me.

Working with Phoenix especially has kind of worn me down. I feel like this ecosystem would benefit a lot from a concerted effort to create more “best practice” example applications and showcase them.

You should consider making a post following the template in the OP Scott - it could prove useful and being more specific could be helpful to the relevant teams.

1 Like
  • What first drew you to it (how long ago!?) and what keeps you here?

The BEAM and a coworker who was a big advocate of Erlang – and was looking to use Elixir to build a large distributed system, roughly 3 years ago. I really appreciate having a “running” stateful system in the BEAM; it’s more like programming video games (what got me into programming originally).

  • How have you found it has changed over the years?

I think Erlang has changed more than Elixir over the past few years. The addition of LiveView has been both exciting and terribly frustrating for me.

  • How have you changed, perhaps while using it?

Writing things as pure functions whenever possible has really helped me to produce more testable and solid code. It’s interesting to me to watch as FP ideas like the ECS model are really moving heavily into game development now, producing data-oriented systems that end up producing more composable code while boosting performance.

  • Which language did you come from?

Primarily C#, Java, PHP, JavaScript (NodeJS) and AS3 (a lot of multimedia and industrial systems work).

  • How are you finding it?

I have a love/hate relationship with it.

There are many aspects of the platform I love: the immutability, pattern matching, friendly community, the BEAM.

There are other aspects I find intensely frustrating, mostly working with Phoenix or GenStage, especially trying to find good, “best practice” examples. I often feel like the documentation is written with unstated implicitly required background knowledge. Often, I feel helpless, facing unknown unknowns that I’m unable to even begin resolving. I’ve worked in a number of languages and platforms over the last 20 or so years, and nothing has made me feel quite so on the verge of drowning as Phoenix.

  • How do you think you’ll use it?

I’ve been using it in production, replicating live data in a large cluster across a series of data centers, modeling millions of users (in the “actor” sense, where people are modeled as processes) at once and upgrading code live with zero downtime.

  • Which bits are you finding easy, which, not so much?

Learning FP practices and how to work with the BEAM were the largest initial hurdles.

Elixir is now very comfortable as a language for me, except for macros, which I still struggle with.

Deployment has been challenging for us, but I don’t think that’s unusual when building a large system with self-hosted servers.

Phoenix has been my largest pain point by far.

  • Is there anything missing that you’d like to see included?

I think having a well-maintained set of best practice example applications would be highly beneficial to the ecosystem, especially with things in constant flux like LiveView.

I think writing the Phoenix documentation from scratch – using test developers without RoR backgrounds as guinea pigs would also be super helpful.

5 Likes

Discovered it about 6 years ago, been obsessed ever since.

Finally doing Elixir full time as of 2 weeks ago.

5 Likes

How did you manage to land your first bit of Elixir work?

1 Like

That’s a long story. The short version is that there’s a growing Elixir presence in my area (Greenville, SC).

1 Like

Sorry to hear you’ve had difficult experiences. Are there any concrete examples that come to mind regarding all this? I’d be really curious to understand what the pain points in Phoenix are for you.

3 Likes
  1. As a new Elixir user, I think it boiled down to the fact that Phoenix is chock-full of macros, so it can feel incredibly awkward using something that seems so suddenly different than the language itself.

  2. Phoenix is full of conventions – and these seem to inspired by Rails. Having no background in Ruby or Rails, it felt like the documentation makes assumptions about the end user’s expectations. It leaves “gaps” in my understanding that make me uncomfortable (I think I’d want every automagical association made in the framework explained with footnotes about how/why and where the relevant code configuration and overrides can be found).

  3. Phoenix has been the smallest part of my Elixir work. When I do come back to it, I’ll try to search for online examples or documentation for what I’m trying to do, and too often come up empty. I understand that the Elixir community is smaller than many others, and I’m not the best at searching, but I can usually find something to work with with most other technologies, but I hit walls with it more often than I do with anything else. Maybe my personality or reading comprehension is just strangely incompatible with its documentation or coding style. My latest “fail” has been trying to find a way to embed a persistent LiveView navigation menu in a layout .leex file. I felt it should be simple, but couldn’t even find if/what the convention might be to associate an Elixir module with the template to grab the active uri on mount or handle_params…

And this is maybe my pain point: I wish it were “code first”. I’d prefer templates be an “opt-in” addition, not a default that you can work around. I’d rather work with something that had just had .ex files even. I think for something with such a heavy emphasis on “convention”, I often miss or fail to see the conventions explicitly defined.

2 Likes