Illustration in purple of chemist hand holding a large beeker. Revelry blog post on textchunker rag app for elixir

Elixir Lessons Our Software Engineers Learned, So You Don’t Have To 

At Revelry, we’ve been big fans of Elixir since its introduction by Jose Valim in 2014. A functional, general-purpose programming language built on Erlang OTP, Elixir plays an important part in most of the new product development we do. It’s also the language our engineering coaches help Revelry apprentices become comfortable with.

With new-to-Elixir software developers in mind, we recently asked our engineers to share interesting and/or surprising things they’ve learned with daily use of Elixir. Here are a few that were received with a resounding “Yesss!” from the entire team:

Daniel: A former Reveler once said something along the lines of, “It’s all just functions, modules, and structs,” which went a long way.

Bob: I am a visual, hands-on learner. I found this one-hour tutorial very helpful for getting a basic overview; I got my iex working and followed along and coded all the examples as he taught.

Dan M.: All those functions that have the same name… Yeah, that’s not a mistake. It’s Pattern Matching.

Jason: Pattern matching is everywhere, including things you think you already understand like result = {:ok, "Success"}.

Stuart P.: Functions are identified by both name AND arity. (Arity is a fancy word for “the number of arguments”.)

Jason: Lots of your favorite algorithms rely on mutability, so accept that it’ll take time to adapt to immutable data. Once you get it, you can take what you learn to other languages and you’ll have fewer bugs.

Daniel: Everything is run by processes on the BEAM, and you can send messages from one process to another. A genserver is a process and a liveview is a genserver.

Brandon: Lists in Elixir act more like the stack data structure than a queue. Leaning into thinking of it as a stack helped keep me from fighting against how it actually works.

PJ: Spend plenty of time getting comfortable with changesets and forms.

Jason: Instead of relying on analogies to other languages (“A Map is like an Object in JS, and a List is like an Array.”), try to map to more general programming principles (“A Map is a generic key-value structure and a List is a linked list.”).

Stuart P.: Enum.reduce/3 is one of your new best friends.

Eric: If you get sick of typing MyProject.MyModule.MySubmodule.my_function all the time, put some aliases in a file called .iex.exs like alias MyProject.MyModule.MySubmodule; anything in that file gets executed automatically when you start a shell in that directory.

Chris: Go through the lessons on elixirschool.com. It’s definitely my favorite learning resource. Elixir in Action by Saša Jurić is another good read.

Stuart P.: You will accidentally use a charlist 'charlist' instead of a string 'string' at some point and tear your hair out looking for the bug. You will also accidentally create a charlist when you have a list of numbers at some point and tear your hair out looking for the bug.

Eric: Get good with the iex shell and in your projects run it using iex -S mix or iex -S mix <your command>, so your modules and dependencies get loaded.

Eric: iex> h AnyModule.any_function gives you help even on your own functions.

Brandon: With iex,  if you forget to assign something to a variable, you can just do variable_name = v() and it’ll work. v() gets the last result and v(number) gets you the result of whatever command was at that number.

Brandon: If you get stuck because you have a ” or ( somewhere – but you don’t know what you need to close out of it – you can just do #iex:break. It’ll break you out, so you can keep going without having to get out of iex.

Want to chat about Elixir – or share something you’ve learned using it? Contact us, or share / tag us at @RevelryLabs on X.

We're building an AI-powered Product Operations Cloud, leveraging AI in almost every aspect of the software delivery lifecycle. Want to test drive it with us? Join the ProdOps party at ProdOps.ai.