abreujp

abreujp

I’ve published a new article in my Elixir learning series on dev.to exploring module attributes - the compile-time annotations and constants that describe and configure our modules.

The article covers:

  • The three roles of module attributes: annotations, temporary storage, and compile-time constants
  • Setting and reading attributes, and how compile time differs from runtime
  • Using attributes as constants, including inside patterns and guards
  • Precomputing values at compile time and exposing them through functions
  • Documenting modules and functions with @moduledoc and @doc
  • Describing function contracts with @spec and typespecs
  • Defining custom types with @type, @typep, and @opaque
  • The @vsn, @derive, @behaviour, and @impl attributes
  • Registering custom attributes with Module.register_attribute/3 and accumulating values across the module
  • Practical guidelines for when to reach for an attribute instead of a plain function

With complete working examples you can copy into IEx, you’ll learn how module attributes become the glue between documentation, configuration, and compile-time behavior - and how they shape the Elixir code you read every day.

Check it out:

Where Next? Top

Trending in Blog Posts Top

New
fuelen
I finally found time to write down my journey away from ExMachina, including the workaround I tried first and the API experiments that fo...
New
T0ha666
An automated trigger fired every two minutes for 8 hours. 243 agent runs. 31M tokens. $63 wasted. The problem: nobody noticed until morni...
New
lawik
The words are insufficient to describe what transpired. What we tried to do met what the people wanted it to be. It became beautiful. Th...
New
davejs
Hi everyone, I’ve been building BetterTyping (https://bettertyping.org) on and off since 2021. It’s a free typing game: practice alone, ...
New
funboy
Turns out a 1ms network hiccup is enough to silently lose broadcasts for a node and that node is just quietly wrong forever Wrote it up ...
New
AstonJ
If you’ve found an interesting or cool Elixir related blog post and think it’s worth sharing please add it to this thread :icon_biggrin: ...
New

Other Trending Topics Top

KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
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
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
ausimian
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews