I’m an Erlang developer originally but have been working with Elixir for a while now. The quality of the Elixir toolchain, libraries, and community is fantastic. The focus always seems to be on modern tools and modern development best practice.
In particular I’m a massive fan of mix format
. Code consistency is so important for readability and it’s great to see this as a first-class citizen in Elixir.
I feel like this is an area where Erlang is lacking. We have erl_tidy but in my completely biased opinion it makes Erlang code harder to read!
I’ve been building Steamroller to bring more of an Elixir-flavour code format to Erlang. It’s opinionated, which means you can change the line length and nothing else, and it’s super early stage, which means you can expect it to break if you try to run it on a large codebase. It can handle the rebar3 source code, but at the moment can’t deal with everything in the OTP source.
Steamroller works by tokenising the source code with erl_scan:string
and formatting that. Any existing formatting is blasted and everything is standardised. The abstract form is checked before and after formatting to make sure that the code is still functionally the same.
You can get it from hex as a rebar3 plugin: {plugins, [steamroller]}.
You can run it with: rebar3 steamroll
and as part of CI: rebar3 steamroll --check
Roadmap as of 2019-12-12:
- Autoformat the OTP source code without crashing
- Tidy up, refactor, and document the source so it’s not a total mess
- Add whitespace padding similar to Elixir
- Consider changing the indent from 4 to 2 spaces
- Add editor integration for people who don’t use Vim
Feel free to try it out and complain at me when it breaks. Aim is to work on it gradually through 2020 and get a polished v1 by the end of the year. Comments, feedback, bug reports, and improvement suggestions are all welcome!