Last October I discovered an interesting Github issue, Elixir-Lang #6643. It was opened José Valim, the creator of Elixir.
Here's part of the introduction to this issue:
Elixir master now includes a code formatter that automatically formats your code according to a consistent style.
We want to convert Elixir's codebase to use the formatter on all files. We understand this means a lot of code churn now but, on the positive side, it means we can automatically enforce and/or format future contributions, making it easier for everyone to contribute to Elixir.1
This issue set off a massive refactoring project to get Elixir conforming with its new formatter. Today, new pull requests to Elixir must pass through the formatter without requiring changes. I think this will have a ripple effect on every Elixir project in production.
While closing this issue, José provided the following statistics on the refactor:
- 425 files
- 214 pull requests were opened
- 84 committers contributed
- 368 commits were added
Most interestingly to me, the entire project took just four days to complete. I think this shows power of the community and the effectiveness of the tool.
This is a big change that affects everybody who writes Elixir. As an open-source Elixir project maintainer, it led me to some questions, such as: what is autoformatting? Why should I care? What is it going to do to my code?
After some research, my conclusion is we should all format our Elixir code now. It's the future of this language.
I started thinking about this tool and its importance a lot this year, leading to this blog post. Continued investigation led to a talk that I presented at ElixirDaze 2018 in Denver, CO. I focused on this history of autoformatting, arguments for and against the practice, and practical applications for a production Elixir application.
Elixir mixologists of every experience level will leave this talk with a better understanding of this important tool, and a deeper grasp of the persistent debate around code style. Thanks to ElixirDaze, the great attendees I met, my friends at the ChicagoElixir Meetup for vetting my talk, and Hashrocket for continuing to sponsor my public speaking adventures.
Photo credit: Samuel Zeller