Get the latest tech news

Avoiding recompilation hell in Elixir with mix xref


Recompilation hell: what it feels like Elixir is an amazing language and it’s been a huge privilege being able to work with it for over a decade now (how time flies)!\nI’d like to point out an issue that, if overlooked, can severely impact productivity in your team. Yes, I’m talking about module (re)compilation.\nYou make a few changes to a single file in your codebase and hit recompile. Boom: Compiling 93 files (.ex). Then you make another change and boom: Compiling 103 files (.ex).\n

Click to see output of mix xref --graph lib/a2.ex └── lib/b2.ex lib/b2.ex └── lib/c2.ex (compile) lib/c2.ex As one would expected, B2 depends on C2 during compile-time, since if we modify the result of C2.person/0 to be, ahem,:joe, B2 will need to be re-compiled so that the@person module attribute can be re-evaluated. Now imagine you follow a similar pattern with endpoints, job definitions, schemas, authorization, error handling, data validation, analytics. This strategy is particularly useful for Absinthe: when you break the chain between your queries/mutations and resolvers, you are effectively shielding yourself from transitive dependencies that could potentially impact your entire codebase!

Get the Android app

Or read this on Hacker News

Read more on:

Photo of elixir

elixir

Photo of recompilation hell

recompilation hell

Photo of mix xref

mix xref

Related news:

News photo

Zigler: Zig NIFs in Elixir

News photo

Building a WoW (World of Warcraft) Server in Elixir

News photo

To Nerves from Elixir