christopheradams

christopheradams

The Elixir Style Guide

I was recently asked to step up and become the maintainer for the Elixir Style Guide. It was, I believe, the first, and is now the most popular, community-driven style guide for Elixir.

The guide aims to be very accessible and open to contributions, and if you’re willing to send us your changes and feedback, it’s a great way to give back to the Elixir community that has given us so much.

As the guide says:

Style matters. Elixir has plenty of style but like all languages it can be stifled. Don’t stifle the style.

If you have a little time please check the open issues and pull requests, and leave a comment or question. Looking forward to hearing from you!

Most Liked

josevalim

josevalim

Creator of Elixir

@lexmag, from Elixir, maintains a style guide mostly aligned with Elixir source: https://github.com/lexmag/elixir-style-guide. If we are ever going to adopt something as official, which is unlikely, that one is the most likely.

11
Post #7
Eiji

Eiji

How about merge this guide with: Credo’s Elixir Style Guide and add issue to Credo github project?

Qqwy

Qqwy

TypeCheck Core Team

For some things it can clearly be seen that one kind of writing will be less error-prone than another.

But in many other cases, the exact method used is not as important as that you (and your team) are consistent: Things like tabs vs. spaces, order of pattern-matching in parameters (x = %{} or %{} = x?), names given to exception classes, et al. I really like Credo’s approach of saying “It doesn’t matter which one you like best, but pick one and stick with it”.

I think it is great that we have multiple style guides, because this means that people will stay conscious about the choices w.r.t style they make.

I think that right now we do not need an officially endorsed (or enforced) style guide, because Elixir’s syntax itself is already a great tool to help developers write reasonably readable and consistent code.

christopheradams

christopheradams

Since Credo was mentioned, I’m not aware of anything in the Elixir Style Guide that contradicts it. (We might however be missing a few rules that we should fill in.) I think you should be able to follow any of the style guides and get Credo’s linter to pass.

However, we also have some guidelines that will probably never make it into a linter, such as how to organize your module attributes/directives.

As long as you’re enjoying Elixir and sticking to a style you’re doing well!

eidge

eidge

Having tried go before, I’d just really like to leave my 2 cents here:

Go imposes a style guide, which I found a bit awkward at the beginning but then grew in me as I found it very liberating. Style is one of those things that’s a bit pointless to discuss, any sensible option is more than good enough.

Anyways, forcing a style does have quite a few good things, especially if it comes:

  • No pointless discussions about what one should use.
  • Every repo is just like your own code.
  • You can easily automate it.

I do agree with @christopheradams, if an official style guide is enforced (and the tools to do so are built) it needs to be something minimal and to the point rather than a complete style guide.

Where Next?

Popular in Discussions Top

heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
bartblast
StackOverflow Survey results for 2025 have been published: Gleam - 2nd most admired language Elixir - 3rd most admired language Phoenix...
New
dimitarvp
Hello, I am looking to more closely understand the advantages of the Repo.transact pattern and the quoted disadvantages of Ecto.Multi. ...
New
BigTom
With Phoenix, Liveview, Ash, Oban Web, Nx, Livebook, Beacon, Liveview Native, Flame, Nerves etc all getting mature, are there any major g...
New
sym_num
I created a Forth processor in Elixir. This is my hobby project. https://github.com/sasagawa888/Forth
New
puemos
I’m working on a platform that allows users to add apps and use them in a writing assistant browser extension (https://anycursor.com). C...
New
darkmarmot
At HCA Healthcare (500k employees and contractors), we’re currently experimenting with Elixir for both data integration (to handle parsin...
New
isaacsanders
When I try to run my applications and I haven’t updated the dependencies, the output tells me to run mix deps.get. Why doesn’t the binar...
New
ScriptyScott
Hey Folks, I just spent the last couple of days doing a deep dive into using Swoosh with Amazon’s simple email service, check out this t...
New
PragTob
:wave: I’m currently extracting the statistics calculation part from benchee and stumbled upon how to present error conditions. In the c...
New

Other popular topics Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement