PragTob
Blog Post: 10 Elixir gotchas
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!
Trending in Blog Posts
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
Hi all,
In this article, I make the case for each test owning its setup.
Usually I forbid my AI agents to use the setup callbacks; I mu...
New
As I’ve leaned into AI code generation on LocalCents, the volume I ship has climbed, and my worry shifted from any single change to the l...
New
I wrote about an issue I had with a LiveView application, and how I solved the problem by debouncing updates server-side (within the Live...
New
I’ve published a new article in my Elixir learning series on dev.to exploring what happens when tagged tuples aren’t enough - the try, re...
New
This article demonstrates how to build a minimal stateful process using only Elixir’s core concurrency primitives: spawn/1, send/2, recei...
New
A recent ex_money v6 upgrade was blocked because Timex pins an old gettext. Rather than one big remove-and-rewrite PR, I used a shim: a m...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance











First 10 of 44 Posts
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
Great one! Would have fit well in the current post with all the
nilshenanigans but I’ll add it to the list for a follow up!D4no0
The chapter
How to use constantsis 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/3to 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
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
Ah my bad, you could also point out that a private function can be used for the same thing.
PragTob
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
Related list collected a few years ago on this forum: Elixir Gotchas and Common Issues Wiki
PragTob
Some great ones in there, thanks!
dwark
I got caught off guard by:
After checking, the docs spell it out neatly once I starting looking for an explanation
(
--is right-associative).PragTob
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