PragTob

PragTob

Elixir is a great language, but some behavior can be unintuitive, confusing and in the worst case lead to bugs. So, I took a look at 10 Elixir gotchas explaining why they exist and how to avoid them!

Showing Posts 1 to 10

BartOtten

BartOtten

Great post.

One more: is_atom(nil) == true as nil is an atom. However, most people mean a defined atom and not ‘undefined’ nil.

PragTob

PragTob OP

Great one! Would have fit well in the current post with all the nil shenanigans but I’ll add it to the list for a follow up!

D4no0

D4no0

The chapter How to use constants is a little bit misleading as module a attributes have not been built to be constant in their design, even though we use them for that.

I agree that a new option for Module.register_attribute/3 to enforce it to be constant would be nice, even though I never saw the immediate need for that as if you respect the fact that you define attributes on top before code, this problem goes away.

PragTob

PragTob OP

I mean, the post mentions that they aren’t actually constant and more of a work-around but also linking to the docs saying to use them as constants. I don’t know how I should make it clearer there while keeping some brevity and not making it the entire topic of the post.

D4no0

D4no0

Ah my bad, you could also point out that a private function can be used for the same thing.

PragTob

PragTob OP

Already updated with that - or well a public function to keep it accessible. I discussed it a bit with José, there are some things that just don’t work without module attributes or would require other workarounds.

michallepicki

michallepicki

Related list collected a few years ago on this forum: Elixir Gotchas and Common Issues Wiki

PragTob

PragTob OP

Some great ones in there, thanks!

dwark

dwark

I got caught off guard by:

 [1, 2, 3] -- [1, 2, 3] -- [1, 2, 3]
[1, 2, 3]

After checking, the docs spell it out neatly once I starting looking for an explanation
(-- is right-associative).

PragTob

PragTob OP

Oh wow, that’s also news to me! Thanks!

I think the great thing about Elixir is that pretty much all of these are well spelled out in the docs :green_heart:

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
pckrishnadas88
Hey everyone! :waving_hand: I’ve published Part 7 of the Building Distributed Systems in Elixir series, where we build core distributed ...
New
zorn
An educational side project in Elixir, Phoenix, and Tauri. I share what I learned while wiring Automerge into the BEAM, including how I s...
New
mudasobwa
So, instead of wasting my afternoon arguing with anonymous handles on X, I turned to my trusty, soulless assistant and said: “Listen, ple...
New
nathanl
Process labels are useful for visualization and debugging. Here’s why you should use them.
New
abreujp
New article: Elixir Project Structure — From mix new to a Growing Codebase I’ve published a new article in my Elixir learning series on d...
New
andreasronge
What happens if you design tools for LLMs instead of letting LLM use human tools ? Wrote a blog on why and what that enables. As I see ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews