3 ms·
I'll never understand code formatters. For me the idea of my code passing through a formatter, is like if accidentally I lost part of it: there is a lot of care
by antirez 10y ago
I'll never understand code formatters. For me the idea of my code passing through a formatter, is like if accidentally I lost part of it: there is a lot of care in the way you write your code, even in the part that the compiler does not care about: spaces. Spaces are the rhythm of the code... not sure why one would write code without rhythm and later add a synthetic one.
- scardine 10y agoThat is one of the reasons I'm stuck with Python, I find it pleasant to read (I'm almost as productive as I used to be with Perl but at least I can understand my own scripts 6 months later). I know, many people can't stand significant white space... The idea sounded weird for me too but after trying it for awhile I was hooked.
- sergiotapia 10y agoBecause your rhythm might be unique or confusing to your team members. Using a tool like this you all share the same rhythm. No ones feelings get hurt, onboarding is simpler, code is easier to read.
- curun1r 10y agoThere's two reasons, to me, why formatters make a lot of sense. First, working in large teams, not everyone will agree on a formatting convention and it's very difficult for people to internalize the convention and stick to it. This leads to, at best, inconsistencies in the code and, at worst, bike shedding discussions on which conventions to use that distract from shipping actual features. When HBO's Silicon Valley had its lead character lose out on a promising relationship because of a spaces vs tabs argument, it hit dangerously close for those of us that have had to endure a months-long meetingfest to arrive at a company standard for code formatting. Once you've been through that hell, you can appreciate the simplicity of just invoking a tool during the build process. Second, there's what I'd call the "Mark Zuckerberg clothing" reason. When asked why he always wears the same style clothes, he said, "I really want to clear my life to make it so that I have to make as few decisions as possible about anything except how to best serve this community." Similarly, code formatting doesn't deliver value to customers/users. The more you can ignore it, the more you can focus on other things. When I first started using code formatters, they irked me greatly. But once you get used to them as a part of your process and start to feel comfortable reading the code they spit out, they transition to being liberating. The formatting fades into the background and all you see is the logic in the code. And I didn't realize just how much time I was spending getting indentation levels correct and aligning things until I entirely stopped doing those things. Now I write code that looks really ugly until I hit save and then it looks exactly the way that the rest of my code looks.
- to3m 10y agoI've found this too. Also: my code formatting has always been a bit unusual, in that I never put spaces in. Compared to what most people do, this is easier to type, because it doesn't require pressing the space bar as much. So code formatters are good for me, because I can keep not pressing space, and now nobody need ever know. But, guess what: this means code formatters are good for you too. Because now you don't have to press space either.
- jlongster 10y agoYou might be surprised at the quality of the output (obviously I'm biased). We've tried to choose what most people consider to be the best way to style code, and many times prettier ends up formatting complex code better than I would have manually. Also, the biggest benefit that a lot of people don't realize is it allows you to quickly restructure your code easily: http://jlongster.com/s/refactor.gif http://jlongster.com/s/refactor.gif I understand if the way prettier formats your code is not the way you would like, and is more of a hindrance than helpful. But I hope the above gif shows why it is freeing for a lot of people. Also, note that prettier does keep the original blank lines in your code. That's where most of the rhythm comes from, and we allows authors to group code however they want. The rest of it is basically choosing whether to insert a space here or there or not. I respect your work, antirez, and I hope you at least try it once! It's totally fine if it's not useful for you though.
- antirez 10y agoHello! Don't get me wrong, I'm not saying that code formatters are not useful, they are massively useful in order to turn badly formatted code into more readable code, and also when there is to integrate some code from a code base to another and needs to be re-formatted and so forth. What I find odd is that there are people using it as a "to go" solution for code indentation. The fact btw that it keeps the original blank lines is a great feature that saves a lot of semantics. Thanks for your comment!
- dang 10y agohttps://twitter.com/paulg/status/710911208849678336 https://twitter.com/paulg/status/710911208849678336
- blake8086 10y agoI think this is because you view yourself as more of a code author, and people excited for this announcement more frequently find themselves in the role of a code reader.