Erlang

Top 5 Elixir "Gotchas"

by Erlang Solutions

Concluding our #ElixirOverload week is a case study from our Elixir Team at Erlang Solutions listing mistakes or oversights that can commonly occur, whether you’re a global company or a new startup.

Categories in this case study entitled Top 5 Elixir Mistakes are clearly defined. Each section will look at the symptoms, what to look for, root cause and how to move forward from this:

  1. Too much config
  2. Too many agents
  3. Too many macros
  4. Simplicity slipping away
  5. Do I need a process?

Our Elixir experts run code reviews and they can spot an issue a mile away. Many Elixir code reviews have similar errors, incorrect patterns, regardless of the system size. Here is what they have to say…

Too much config

Abusing config files, leading to code that’s not flexible at runtime. This is particularly relevant for library authors. It’s preferable to provide public APIs which accept config options, so that we maintain flexibility.

Too many agents

Claudio Ortolina: “If a process is named, it means that it’s a singleton in the whole system and needs to be designed with care to not become a bottleneck.”

It’s easy to reach out for an Agent to store some data. This comes at a cost though, which is the introduction of a bottleneck. It’s always important to think about how the introduction of a new process may affect the overall system performance.

Too many macros

Most macro usages can be replaced by function calls. Use macros sparingly, only when you absolutely need to modify the code at compile time.

Simplicity slipping away

A code base that is hard to get to grips with. What’s it like when a new team member comes along to a project? How long do they have to riffle around in a code base before they get to grips with it enough to deliver value? If the answer is too long, given the project size, then this can indicate that simplicity is slipping away.

Do I need a process?

Szymon Mentel: “The thing is to have the processes in balance. The Erlang VM is known for being able to run hundreds of thousands processes concurrently, but before getting there make sure there’s appropriate rationale behind that.”

The full version of Top 5 Elixir Mistakes can be downloaded in a PDF format from our case studies section. It is the first case study you will see. There, you will also find other case studies such as Elixir vs Erlang vs Go; an infographic detailing the important similarities and differences between the BEAM languages.

We have hundreds of BEAM specialists across the world with a passion for open source technologies. They can help with consultancy to development of your fault-tolerant Elixir system. These systems can scale to BILLIONS of users. If you’re interested in consultancy or development, or would like a review of your system, contact us. We’ve also introduced our new Elixir Architectural Sessions.

Special thanks to our Elixir Team; Claudio Ortolina, Szymon Mentel, Joseph Yiasemides and Arkadiusz Gil for preparing the case study and additional quotes.

Go back to the blog

×

Thank you for your message

We sent you a confirmation email to let you know we received it. One of our colleagues will get in touch shortly.
Have a nice day!