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

New
fklement
This is a thread to gather some information about the efforts of using elixir in combination with cars or vehicular systems in general. ...
New
AstonJ
Have you changed the way you learn? Maybe you started off using docs and tutorials and are now an avid book reader or course watcher? Or ...
New
AstonJ
Bart’s talk about Hologram got me wondering what kind of apps or components people are thinking about building (or think could be built) ...
New
ryanrasti
Hey everyone – after coming off of 3 years building with Ecto, I’ve been working non-stop on Typegres, a new query builder that strongly ...
New
lessless
I wonder if it’s possible to mimic a simple “class reopening”/inhertinace-based SEAM in Elixir to alter a module’s behaviour without edit...
New
yordisprieto
I am trying to figure out a good architecture and implementation for authZ. Recently, I discover GitHub - open-policy-agent/opa: Open Po...
New
chrisliaw
Hi, I’m wondering is it my thinking process or this is the norm among the Elixir developer for the use of Struct and accessor functions ...
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
AstonJ
There seems to be a lot of buzz around DeepSeek at the moment, with some saying it’s a ChatGPT killer. The most remarkable thing (if they...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
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
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement