As you requested, this is now a separate topic.
The genesis of the formatter was as the solution to a real problem: the Elixir core folks wanted to keep their source consistent even as they received PRs from many different sources in many different formats (guilty!). The current tool does a good job for them.
But does it solve a general problem? I'm not convinced. Have Elixir users complained in volume about the lack of a tool that would format their source the way the core source is formatted? I haven't seen that happening. Instead, I see teams that agree locally on things that are important to them.
And I think that's important. Having a tool that formats source is useful, but mostly in the context of accepting submissions from a heterogeneous base of developers. In house, I think formatting is something to be discussed, tried, and refined, rather then being imposed. Why? Because formatting is a useful activity when you're writing code, as well as when you read it. Formatting as you go makes you think about structure—if something is hard to lay out nicely, perhaps it is just plain ugly code. Removing the formatter from the core signals that it's a tool to be used in certain circumstances, and not on every git push.
So, the more I think about it, the more I think that taking formatting out of the core is the way to go. Package it as a free standing tool. Make people use it on Elixir core PRs. Let people use it when they want. (I'll happily use it if I'm trying to understand code that looks like it was written by a team of drunken pigeons.)
Take it out of core, and it won't seem to be the "officially blessed format that we all must use." Take it out of core, and these discussions will evaporate. And that'd be an instant productivity boost :)
Dave
I see your point Dave, but I think taking it out of core to, say, elixir-lang/formatter would still make it the "officially blessed" formatter. As for the "we all must use" part, the formatter is currently definitely opt-in in any project: you still have to run mix format manually, or set up your editor to run it for you, or set-up CI, and so on. The Elixir team just chose to go with the formatter on the Elixir source because of the reasons you mentioned, but this doesn't mean the formatter is enforced anywhere outside Elixir.
I see teams that agree locally on things that are important to them
Teams can keep doing this and ignore the formatter completely, and it will be exactly like if the formatter wasn't in core (or didn't exist at all 😄).
For the reasons above, I am 👎 to moving it out of core.
TL;DR: you can ignore the formatter and everything will be just as if it wasn't in core, and if we move it outside of code it would still be the "official" formatter.
Let me come at this a different way.
Why _should_ it be in core? Core is a place of privilege: things must
justify their place there.
Mix has a place, because elixir is not really usable without it.
Exdoc does not have a place because many people don't use it, and it
doesn't _need_ to be there.
Formatter has a place because...??
Dave
On Fri, Jan 19, 2018 at 3:36 PM, Andrea Leopardi notifications@github.com
wrote:
I see your point Dave, but I think taking it out of core to, say,
elixir-lang/formatter would still make it the "officially blessed"
formatter. As for the "we all must use" part, the formatter is currently
definitely opt-in in any project: you still have to run mix format
manually, or set up your editor to run it for you, or set-up CI, and so on.
The Elixir team just chose to go with the formatter on the Elixir source
because of the reasons you mentioned, but this doesn't mean the formatter
is enforced anywhere outside Elixir.I see teams that agree locally on things that are important to them
Teams can keep doing this and ignore the formatter completely, and it will
be exactly like if the formatter wasn't in core (or didn't exist at all 😄
).For the reasons above, I am 👎 to moving it out of core.
TL;DR: you can ignore the formatter and everything will be just as if it
wasn't in core, and if we move it outside of code it would still be the
"official" formatter.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/elixir-lang/elixir/issues/7233#issuecomment-359095871,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAApmO_oM-2XXg3zeuraVRmlHekV2geaks5tMQrtgaJpZM4RlA0o
.
Because I dont want to be adding a dependency for something that I will use 100000% of the time.
Probably I would say the same of ExDoc, I hope it gets into an stable version and be add it into the core.
P.S: I wouldn't expect ExDoc or Formatter code into the production release but that is a simple detail to fix.
The reason I'm happy to have an official formatter that's part of core is because it takes an entire chunk of potential disagreements within my team - or any other team I may be a part of, including open source libraries - off the table. Every Ruby team I've ever been on has had discussions about formatting and style, and they always end up being contentious and rarely are they worth the argument. I honestly know people who have hurt relationships with co-workers over style disagreements. By having it in core it says "we _recommend_ you do this." By having it outside core it says "you _can_ do this." I believe the recommendation is justified.
Styling is one of those things a computer can do really well. I'm happy to not even have to think about it anymore. And the funny thing is, after enough time, I won't even notice the difference. After just a couple weeks with the new styling rules, I'm already finding myself used to this new style. The muscle memory is there, and I can read things just fine that I previously thought would be problematic.
If someone doesn't agree with the rules, they're under no obligation to format their code using mix format. If someone would like to create their own formatter that's extensible and configurable, they're still welcome to do so. However, for me (and for a great number of other devs), having an official style just means it's one less thing to think about so I can focus on solving real problems.
I did some study on this before my ElixirConf EU talk last year, and according to the research I could find on the topic, it turns out that formatting just isn't that important when it comes to comprehension (see the paper Does signaling help professional programmers read and understand computer programs). From that paper:
Typographic signaling helps, but not that much. Research on text comprehension agrees with these findings.
So, I see no reason to even worry about it. Formatting is one of those things that _feels_ important, but it turns out that as long as you're consistent, it doesn't matter what we do. Like with driving, it doesn't _really_ matter which side of the road you drive on as long as we're all driving on the same side.
Formatter being part of Mix predefined task improve the community and the coding experience of Elixir, a lot of people still talking about formatting in 2018, being unproductive about, or when you work with people that just don't care about you make it hard for the one that do. With such of tool out of the box there is not more concern about it and people do not pay attention.
Learn from other super messy ecosystems like Javascript, where people can't agree about semicolons and tab/spaces
Unproductive.
I would download 1GB of code for having such of tooling out the box, I wouldn't expect to compile it into production for sure.
Also, take into consideration that many of us, like me, are beginners 🔰 Having such of tool helps to contribute in open source projects without worry about such of details ....
And so on.
I do think that Dave's arguments makes a lot of sense. In a way I don't like so much about the way Go forces you to uses its formatter. if your code is not formatted it doesn't compile. Some teams prefere doing the formatting of the code on different ways that makes more sense for them. that includes ways of writing DSLs etc...
But even tho. I think formatter should stay on the elixir core. Is great to have a way to tell everybody that uses elixir to just run a command and your code will be shippable on mostly projects, without having to deal with 🚲 .
I have divided thoughts about this issue to tell the truth.
It seems we had different experiences so far @pragdave. :) From my perspective, the formatter has been extremely well received and is being actively used by OSS projects and companies.
The reason the formatter was created was not actually because of pull requests in Elixir Core. I was actually totally fine with formatting contributions. The trouble is that the team members, which is a small group, could not agree on a standard to follow. Even when we documented it, we would make mistakes, and sometimes we would spend precious time talking about style rather than design and APIs.
I saw similar issues at projects inside companies, where they would rely on linters, such as Credo, to emit warnings on style violations, which provided a very slow feedback cycle: they would submit a pull request, a bot would leave a code style comment, then they would fix it. I would like linters, humans and bots to focus on the code, not on formatting, and the code formatter allows that.
Take it out of core, and it won't seem to be the "officially blessed format that we all must use."
Except that we want it to be the "officially blessed format that everyone should use". That's exactly why the formatter exists: to promote a consistent style across the community. But if you don't want to use it, that's fine.
Similar argument could be done about ExUnit. It is not actually necessary in Elixir but we feel like everyone should be writing tests: so having it as part of core helps push the message forward.
Take it out of core, and these discussions will evaporate. And that'd be an instant productivity boost :)
Quite the opposite: if we remove the formatter, then many teams and open source projects will repeat those discussions over and over again.
If the goal was to evaporate discussions, we could also just say that the formatter is done and that's it, the formatter is what it is. But I don't think this would reflect how Elixir has been developed all these years. We like to listen to feedback even if at the end the answer will be "sorry but nothing will change". Which curiously, is also the answer here. :)
In any case, thanks everyone for the feedback! We have no plans to remove the formatter from Elixir.
Most helpful comment
It seems we had different experiences so far @pragdave. :) From my perspective, the formatter has been extremely well received and is being actively used by OSS projects and companies.
The reason the formatter was created was not actually because of pull requests in Elixir Core. I was actually totally fine with formatting contributions. The trouble is that the team members, which is a small group, could not agree on a standard to follow. Even when we documented it, we would make mistakes, and sometimes we would spend precious time talking about style rather than design and APIs.
I saw similar issues at projects inside companies, where they would rely on linters, such as Credo, to emit warnings on style violations, which provided a very slow feedback cycle: they would submit a pull request, a bot would leave a code style comment, then they would fix it. I would like linters, humans and bots to focus on the code, not on formatting, and the code formatter allows that.
Except that we want it to be the "officially blessed format that everyone should use". That's exactly why the formatter exists: to promote a consistent style across the community. But if you don't want to use it, that's fine.
Similar argument could be done about ExUnit. It is not actually necessary in Elixir but we feel like everyone should be writing tests: so having it as part of core helps push the message forward.
Quite the opposite: if we remove the formatter, then many teams and open source projects will repeat those discussions over and over again.
If the goal was to evaporate discussions, we could also just say that the formatter is done and that's it, the formatter is what it is. But I don't think this would reflect how Elixir has been developed all these years. We like to listen to feedback even if at the end the answer will be "sorry but nothing will change". Which curiously, is also the answer here. :)
In any case, thanks everyone for the feedback! We have no plans to remove the formatter from Elixir.