-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure tab length #210
Comments
2 spaces is also very popular. Having an option to change that would be really awesome. |
A core goal of elm format is to have a single formating style. Can you provide more details about why allowing different lengths is desirable? |
A consistent formatting style throughout a project is excellent. Why enforce such a setting universally without providing an option? Some projects have an .editorconfig file to specify such choices. Perhaps elm-format could be extended to follow what is specified there. |
Many text editors, Atom for example, have the default tab length set to 3. In case you are using a code beautifier with default tab length set to 4, as elm-format in this situation, your code turns into a mess, because of unaligned lines which cause additional errors. Thought it can be fixed with changing default tab length or specifying tab length for elm-files only, I think it's not the right solution, to set custom tab length for every language you use. Maybe there could be sth like tab length recognition system behind the scenes, if not config file? |
I prefer two spaces so I'm compiling from source, the only change needed for that as far as I can tell is to change the |
See #158 for a discussion on why it is important that it never be configurable. |
I would much rather have a level of configurability a la |
Tab length
There aren't too many Elm users yet, so you may think it's simple to convince them over style. But no matter what style guide says, some people will fork I'm pretty new to Elm, played with it few days and I see that in current state that's completely unreasonable to have so called "style guide" while standard library not following rules written into @rtfeldman whole topic #158 tells me exactly that fact - people want it to be variously different. While I'm not against "4", telling other people that "4" is the best number for them is simply rude IMHO. I don't want to start flame war but please understand that people have reasons. @avh4 This comment #158 (comment) tells me basically nothing. You showed some percentages without numbers as a good statistical social proof, closed the topic and gone away. But what I'm mumbling for is not just tab length. Not only tab length!Honestly, I believe there's much more to configure than tab length. Consider this:
I don't know about your job but mine is about reading a lot of code, not only writing it. Thus, I would prefer less scrolling while analyzing already written stuff:
^ this is just better to me in larger scale. Too great number of newlines is a false positive to better legibility. But hey, some people would desire seeing this - aligning
But there's more I don't like, just look at it: daysPerWeek =
7
defaultCalorific =
2100
defaultWeekCount =
4 ^ 3 lines would be enough, really. And giving 2 empty lines between definitions? Why not 1? Another thing, let's cite some part of "style guide" (about Line Length):
consider is big word here. 80 is a small number. That's just an another opinion of mine. SummaryConfiguration is what we want. Non-modifiable rules over style are not acceptable because things like that divide community abandoning some efforts like yours. Please step back in history, look at all other programming languages and count successes about style guides that you're trying to achieve here. Just to note C++, Java, even C# and I won't even mention JavaScript or TypeScript (oh, I did). And the last thing - don't get me as "yadda yadda he's complaining" but as a strong opinion handler, which I believe many people are but don't want to spend time on writing same thoughts. And thank you for all your effort @avh4 @rtfeldman |
This is because Evan doesn't want to rewrite the official docs every time
As @avh4 noted, a core goal of Just to be super clear on this, you fundamentally disagree with this core goal, yeah? |
The official style guide optimizes for minimal diff-noise. Some people would much rather optimize for concision when it serves readability. Letting each project make that decision for themselves seems nice. |
@rtfeldman Thank you for your response. To be super clear, it doesn't matter.
@crazymykl That's huge what you just wrote! Besides this, I have nothing else to add. Just wanted to make a small place to vote. |
Shouldn't this conversation then turn from "change |
Yes, or perhaps even "Should a language endorse/enforce a single style." IMO, the answer is yes. Languages are, among other things, a collection of idioms. The more idiomatic a language can be made, the easier it is to dive into other people's code. Also: It's just another thing that can be universally automated and verified. |
Ideally, there are no wars, ill people and deaths caused by starvation. In practice, I've just found 5 forks of this project changing spacing 4 -> 2. |
How many forks of |
I want this issue to remain "make |
We can learn from other communities that have already been through this. For example, Haskell has |
I would much rather see |
+1 for configurable tab length. Four spaces is just too much. With two spaces my code is more compact and nice. Having stable tab length across the project will serve the purpose of reducing amount of lines in a diff, will keep same code style and will not have real impact on single formatting style of all projects in the community. People (including myself) are going to fork this project, change tab length and then use own binary. elm-format is a great tool which does great job. Being too flexible is definitely not a right choice but to disallow any flexibility is also a bad option. |
At the very beginning of this thread @avh4 posted: (emphasis mine)
ResponsesHere have been the responses:
Summary of the responses:
ConclusionThe evidence is clear that:
Because of 1, if I would argue that this is not time well spent, but it is time that will be spent (due to human nature, it seems) if it can be spent. One need only scroll up for evidence of this. In conclusion, making ChallengeI would challenge anyone who thinks |
Making time to discuss styling conventions--be it globally (as we do here) or within the microcosm of a team, one time--does not necessarily mean being less productive (it is part and parcel of software development which is not all about writing code). Thus, your challenge has an implicit bias that discussing styling conventions leads to "concrete loss of productive across all elm-format users". Even if--note 'if'--elm-format is to have a single formatting style, the question remains: how is this style choosen? Is it being chosen democratically or from within the walls of NoRedInk? |
Okay then, we'll have to agree to disagree on that premise. 🙂 (I do find it somewhat amusing that I'd explicitly planned to work on a new feature for
As far as I know, Laszlo was the first person to write a public style guide for Elm, so that was the original starting point. It's never been democratic, because as @avh4 noted once on another thread, there's no way to get a representative sample. (Are people who knew there was a vote taking place more important users than those who didn't? What about people who aren't users today, but will be affected by its design in the future?) So I'd say the design has evolved based on discussions of tradeoffs like the issue you linked to. (As an aside, I'm unclear on how a public GitHub issue resides "within the walls of NoRedInk," but that's neither here nor there.) As an example of how design decisions are made, here is an example of @avh4 collecting and publishing data on 2 spaces versus 4 and another example where he talked about collecting input from community members on 2 vs 4.
This is how contentious decisions have been made on this project: collecting information and making decisions backed up by reasoning. For my money (which I guess is none, since this is open-source software that @avh4 makes in his spare time for free), this seems like the best way to go. |
Is the data for the feedback--upon which the current 2-space indentation decision is predicated upon--available in the open for public scrutiny? I ask because I have hard time believing that more people opted for 4-space indentation despite the contrarian votes here on GitHub. I know that NoRedInk--where the creator and some prominent members of the community are employed at--wants to make style discussions moot, but obviating needless style discussions in the name of purported productivity gains does not necessarily mean not being open about the data points that lead to the blessed style in a format. It leads me to wonder if making "style discussions moot" really means making them moot only outside of NoRedInk's walls. |
One more vote for the 2-space crowd. Not because 2 spaces are superior to 4, but because running elm-format on 10 thousand lines of Elm code just broke |
I usually use Elm to implement small parts of Ruby web apps, and it kind of sucks to have two parts of my code base be on different tab lengths. Yes .editor-config is a great thing, but it's not always available and there is some readability argument to being able to have the entire project exactly the same. Being forced to 4 spaces almost stopped me from using elm-format when I first read about it, although I did get over it eventually and the upsides do outweigh the downsides. |
2 spaces between functions and 4 spaces instead of 2 for tabs makes files bigger and larger, and I don't see it as more readable. |
I would add (not in response to the above comment) that, as a long-time user of elm-format, tabs is really the only thing I would definitely like to be able to customize, as I know there is some concern that this is a slippery slope towards a non-unified elm style. I would want to keep it at 4-spaces or whatever the global community default is when writing open-source packages, and some other indent to match the project I am using elm in for proprietary code (often a javascript or ruby pipeline). I don't think one is more readable than the other, I have been using both for many years. I just use whatever the conventions of the project I am working on are. |
This response only deals with @rtfeldman's argument above. Apologies for its long-windedness. Configurability leads to some loss, but not a net loss in productivityPrevious argument:
Completely agree on these points. I believe that most people would.
I'll grant that there is some loss of productivity when debating these things. However, I don't think that this leads to a net loss overall. Consider this:
I feel that the first point alone leads to way more gains than any losses accrued by lunch debates on configuration. There is some value produced from these debatesRemember also that while no single style satisfy everyone, no single style is perfect either. Each has some benefits over another. Example:
Some teams value some benefits over others and make choices about this. Allowing them to make that choice in the end leads to a value gain since they'd only do so if it was worth it. Honestly, this alone is probably a net loss in productivity. However, I'd say most teams have better things to do than debate configuration and I would bet that most people don't actually care. Yes, there are quite a few debates on this repo, but it's filtered down to just the people who care enough about formatting and Elm to be reading issues on a ticket for Configurability does not lead to the loss of a blessed styleWhile some people will have small divergences from the standard, most will not. Not a perfect analogy, but take maven and gradle as examples of configurable tools. Obviously these tools allow for a large amount of flexibility in configuration, but maven and gradle are highly opinionated on how they should be configured. Those settings are largely untouched because changing them is only done in extreme cases. Granted build tools require more flexibility than formatters, but opt-out behavior in general is well studied. Default values for configuration ensure that a blessed style exists. ConclusionOverall, you still retain a blessed style and improve productivity by introducing configuration. In my opinion, not doing so for the sake of improving global developer productivity is missing the forest for the trees. |
Not gonna lie, I feel like "give me what I want or I'll refuse to use this tool and my productivity will suffer" is not a super compelling case. 😉
I work on such a team. Our stack incorporates a variety of languages, and various team members use Atom, Vim, Emacs, Spacemacs, Sublime Text, and RubyMine. We all use Maybe there exist editors that don't play nicely with
On this point we agree! 😸 |
I sincerely hope elm-format never ever becomes configurable. I may not agreed with everything (separate discussions/issues), but not having to care about it in my project because it's the standard is so liberating and frees up precious time to focus on solving actual problems. I have yet to hear any convincing argument (as in because it actually objectively or measurable has any benefit) for making it configurable. Hope this thread closes as soon as possible, with the conclusion no configuration will be catered for. Any issues related to configuration automatically closed with a short statement stating why it will not ever happen. End of 😄 |
@rundis I agree 100%! |
prettier did not have configuration in the beginning and I loved it. Now it has a few and just last week there was an issue in the company regarding usage of double quote vs single quote. Some did not want any configuration so initially, we went with prettier default which is to double quote all the strings. However, folks who have been doing ReactJS for a while did not like it since ReactJS and some other famous JS tools use single quote. I hope Elm grows. I hope elm-format grows in popularity. I hope elm-format is able to withstand the pressure of not adding more configuration. |
For me, the problem with not adding configuration is that it can split the community around the tooling, between the ones who use elm-format, and the others. I know people who do not use elm-format because of the tab length. Me included: I'm using elm-format at work, not for my personal projects. It's too bad to split the community and lose people just because of tab length IMO. If elm aims to be mainstream, I think it's good to keep the community focused on one tool, one language, etc. When doing JS, you have hundreds of tools to do the same thing, just because people can't coordinate. What I love about elm is that you don't have such mess. About configuration: a .elm-format file at root of the project redefining the settings for the project do not interfere with standard: if no file is detected, just use 4 spaces. And I think it's important to not tell to newcomers that elm-format is configurable: they can search later when they're accustomed with the tool, and want a little bit more customization. |
In the State of Elm 2017 survey, 91% of respondents who had tried And considering a major selling point of I'm not really sure how that could be justified, to be honest. |
OK, that's your take. I can't make any objective argument to convince the 91%, and I'm not convinced by you either. Maybe it's time to stop arguing and do something else :) Off topic: hope that code formatters of other languages (that I use) (yapf / rustfmt / Prettier in particular) stay configurable. It's so difficult to find a fun language with great ecosystem. |
@rtfeldman Interesting. Do you know the count of people who had tried |
Not offhand, but it might be in here somewhere: https://youtu.be/NKl0dtSe8rs
…On Sun, Jul 23, 2017, 10:32 AM Sridhar Ratnakumar ***@***.***> wrote:
@rtfeldman <https://github.com/rtfeldman> Interesting. Do you know the
count of people who had tried elm-format (in that survey)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#210 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCxwP5SXNZUpT9sWKG-qS3G7IE43-r6ks5sQ1l5gaJpZM4I8KX9>
.
|
Perspective from the bad sideWhen I was learning Elm, I used 6 months later I stopped. I know knew how everyone else wrote their code, but I wanted mine different. Why? Aesthetics. 1. Two spaces over fourComing from traditional JavaScript, I grew up using tabs— but with the advent of React and Babel, 2 spaces became the standard. I’m used to it and it helps me understand indentation levels more easily than 4. Compare: view : Model -> Html Msg
view model =
let
page =
case model.page of
FriendListPage ->
Html.map FriendListMsg
(FriendList.view model.list model.viewState) to: view : Model -> Html Msg
view model =
let
page =
case model.page of
FriendListPage ->
Html.map FriendListMsg
(FriendList.view model.list model.viewState) 2. Excessive use of new linesThis one is fairly trivial but still bothers me significantly. Compare: decodeViewState : String -> ViewState
decodeViewState json =
let
jsonViewState =
JD.decodeString JD.string json
viewState =
case jsonViewState of
Ok string ->
case string of
"Expanded" ->
Expanded
"Collapsed" ->
Collapsed
_ ->
Expanded
Err msg ->
Expanded
in
viewState to: decodeViewState : String -> ViewState
decodeViewState json =
let
jsonViewState =
JD.decodeString JD.string json
viewState =
case jsonViewState of
Ok string ->
case string of
"Expanded" -> Expanded
"Collapsed" -> Collapsed
_ -> Expanded
Err msg ->
Expanded
in
viewState In a ~500 line Elm file, ConclusionBoth for teams and a community, I agree 100% with @rtfeldman about the importance of disallowing configurability. One of my favorite qualities of Elm is how opinionated it is about everything. Because it has the right opinion. And to date, every issue I’ve had with Elm’s opinions, I’ve come round once I understood why. However, I disagree that 4 spaces are better than 2. And I disagree that new lines are necessary after every So, I am a hypocrite: opinionated style and formatting are good. Until they’re not. Out of curiosity, is there a path for changing the official style guide? Or does it come from Senpai Evan? |
Disclaimer: all comments below are written in all seriousness, and I'm mostly a "2 spaces" person, even though I don't mind elm-format rewriting them to 4 spaces.
How does it do that? If your argument was "4 spaces makes lines too wide, overflowing 80 characters, etc", I could objectively see how you came to that conclusion, but how do you see the indentation better with 2 instead of 4? Out of curiousity, what about 1 space instead of 2? view : Model -> Html Msg
view model =
let
page =
case model.page of
FriendListPage ->
Html.map FriendListMsg
(FriendList.view model.list model.viewState) vs. view : Model -> Html Msg
view model =
let
page =
case model.page of
FriendListPage ->
Html.map FriendListMsg
(FriendList.view model.list model.viewState) I hope I don't sound aggresive. I just don't understand the claim. |
@Janiczek Not at all :) When I said, "understand indentation levels more easily", I meant that 2 is what I'm used to because of my JavaScript background. I don't know if there is any empirical evidence around the difference in legibility or understanding between 2 and 4. (Though I do find 2 nicer on the eyes) However, I understand that Haskell uses 4, which is probably why Elm defaults to 4. But most [?] newcomers to Elm have a JS background, not Haskell. |
This is not about which is the best, there is no such thing. It comes down to preference, just as many other things (like ice cream, some prefers vanilla others chocolate). |
I spent a couple hours reading through all the Elm discussions I could find on tabs vs spaces. It's clear that there is a huge division in the Elm community. Most here are sick and tired of this debate. Some think it is resolved while others do not. I fell in love with Elm for a lot of reasons, but the one that stands out the most is that it eliminates most of the tedious debates on which way to do something because it provides one best solution. However, here there isn't a best solution. But we desperately need resolution. Resolution that only Evan can provide. Otherwise it will only continue to divide us and keep recurring year after year. The resolution can look like anything: Why is this debate not resolved?
It also shows a "Good" example using indentation with both 2 and 4 spaces: homeDirectory : String
homeDirectory =
"/root/files"
evaluate : Boolean -> Bool
evaluate boolean =
case boolean of
Literal bool ->
bool
Not b ->
not (evaluate b)
And b b_ ->
evaluate b && evaluate b_
Or b b_ ->
evaluate b || evaluate b_
That does not look like consensus. Additionally, the participators in the elm-format 2v4 discussion break down as follows: Why does it need to come from Evan?He is the creator of Elm. This debate will only be resolved when he makes a stance. Then it can be put on the elm-lang website and filtered down to all the community packages. The current state of indentation@evancz uses 2 spaces:
Of the 30 official elm examples, 24 use 2 spaces: In the Many of the most popular elm packages use 4 spaces: Conclusion and plea!If you read this and dismiss it because it's already been discussed or resolved, please hear me out. Even though I am biased and prefer 2 spaces over 4, it's more important for us to have a standard. Even if the official policy is that indentation width doesn't matter, then libraries like Help us, Evan Czaplicki. You're our only hope. |
The awesome thing about unilateral decision making is that it leads to people taking action that they normally would not have taken. For instance working in many development shops I have discovered that each and every one of them has had different coding styles. What has happened in this particular instance is that the existing coding styles have conflicted with the fact that this formatter does not allow for configuration to cover these styles. Thus all of the shops I have worked in that decided to use Elm (just one) decided that the best course of action was to not argue with the maker of elm-format but rather to fork this repository and make our changes. At the end of the day I guess as long as the primary author of a tool is happy..... 🥇 |
@ghivert would you mind opening a separate issue for that? Seems stearate from this. 😄 |
@rtfeldman I don't think that that is a separate issue. Do you really indent list elements with a tab (key) instead of a single space in lists or after a pipe? Is there someone who does that? |
@ghivert I think the current behavior is correct. Consider the following:
Our three elements are aligned. |
@ghivert Why not just write the contents of the new line (after |
@kuon I agree. But the indent you showed is clearly two spaces. The nested list is two spaces away from the first list. @Janiczek I did it, and the indent guides are still not correct. I just took screenshots to better explain the problem. You can see that the second screenshot is more consistent with the indent guides, as everything is aligned with commas and square brackets, where in the first case, the nested indent guides are badly aligned with the f of focus, but correctly indented with the array (the one with element and anotherElement). However, indent guides on the second array (the one with standard and focus) don't appear. The problem seems easily fixed by setting tab length to two spaces. 😉 |
@ghivert you are missing my point. What I mean is that list content is NOT indented by the tab length. It is the natural indentation of the list. The elements of the list are not indented. They appear indented by two because the coma plus the space are two in width. |
Yes please! @gdotdesign this is an issue about configuration, not how the current indentation algorithm interacts with indent guides, so I'd say a separate issue definitely makes the most sense! |
@rtfeldman I think you are misunderstanding something, as I understand @ghivert comment was ironic and the question was "Should I open a new issue for setting the tab length to two spaces?" Otherwise I don't really understand what the issue is exactly. It's changing the formatting of the lists from: |
I took @ghivert's comment to be sincere, not ironic. 🙂 Regardless, it's a point that I don't think has been surfaced before, and which deserves discussion! |
FWIW, not all of us have the liberty of freely choosing our formatting style. I work as an onsite consultant on a large codebase in Elm that was written by others long before me, and they settled on 2 spaces, and the result is that elm-format is useless to me because I am not at liberty to unilaterally change house style to suit its developers' preferences. You can dismiss that as "unproductive" all you like, but the result is that without configurability, the rest of the benefits of elm-format are lost to me because of this. |
@jarcane I fully understand. But the whole point of this thread is to avoid this kind of issue in the future. I guess we could make a |
The discussion here has gone off-topic multiple times. As a lot of people are subscribed, I'm locking this issue until I have a chance to summarize the points that relate to the original issue. If you have a separate feature idea or suggestion, please create a separate issue. |
Is it possible to change tab length of beautified code? For example from 4 (i guess it's set to 4) to 3?
The text was updated successfully, but these errors were encountered: