5 ms·
The dart formatter is awesome - kudos to Bob. All languages should come with a highly opinionated formatter. It puts an end to useless style arguments.
by wstrange 7y ago
The dart formatter is awesome - kudos to Bob.
All languages should come with a highly opinionated formatter. It puts an end to useless style arguments.
- munificent 7y agoIt doesn't really put an end to them, it just turns them from N×N arguments between each pair of programmers to N×1 where everyone argues with me, the formatter maintainer. But, yes, that's a significant performance win (for everyone except me...). :)
- klodolph 7y agoI hear the author of Black (an opinionated Python formatter) was at a conference and gave a presentation that when something like this: > I'm the author of Black. Questions? Questions, of course, filled up the entire rest of the time slot.
- anthonybullard 7y agoFrom my perspective at least, you've always handled it with grace. Thanks for your work Bob.
- munificent 7y agoYou're welcome! :)
- andrewzah 7y agoI didn't really understand this until I started using golang. Now I don't want to go back to other languages and have to deal with varying syntaxes and manually running a formatter.
- thedance 7y agoWhat's a language that lacks such a facility? ClangFormat covers C/C++/Java/JavaScript/Objective-C/Protobuf/C#. gofmt obviously can do Go. buildifier will rewrite your Bazel BUILD files.
- frosted-flakes 7y agoThose aren't highly opionated default formatters though. The JavaScript community seems to have settled on Prettier as the go-to formatter, but not everyone uses it, and even Prettier had to add a bunch of options for certain things that will always be highly personal. Stuff like trailing commas, tabs vs spaces (and how many spaces‽), line lengths, and semicolons.
- klodolph 7y agoWell, one part of trailing commas in Prettier is that different versions of JavaScript support them in different places. With go fmt, the formatter is updated in lockstep with the language.
- pje 7y agoruby
- andrewzah 7y agoruby has rubocop, although it is more basic.
- nicoburns 7y agoEvery time I use one of these it ends up doing ridiculous things to the formatting, like splitting what should really be 1 line over 4 or 5. Which completely destroys whole-file readability/scanability. Does nobody else find it really hard to read codebases subject to these formatters?
- wpietri 7y agoIt depends for me on the formatter. For me, blank lines are often part of how I express meaning. If the formatter is good at respecting my chosen line breaks, fantastic. If not, it's pistols at dawn.
- lhorie 7y agoDon't just blindly run a formatter. I've developed a habit of refactoring long lines early (e.g. breaking large expressions and assigning to intermediary variables) to prevent the formatter from adding hard-to-read mid-expression line breaks
- deadbunny 7y agoThis is basically the approach I take, write towards the standards of the auto formatter as much as possible and it'll usually handle the rest.
- thatswrong0 7y agoInteresting.. not having to worry about where to break long lines and letting the formatter (in my case Prettier) figure it all out for me has been one of the most wonderful things in recent memory that has happened to my programming experience. I can just write awful looking code at the speed of thought and know it will turn out fine when I hit save. Having to switch back to a non-opinionated non-line-breaking formatter like golang's makes me very sad.
- lhorie 7y agoPrettier outputs fairly decent formatting for code that is already reasonable to begin with. It's not so great when you have things like template strings with large expressions in the interpolation slots.
- jackewiehose 7y ago> It puts an end to useless style arguments. I don't like auto code formatting in my workflow and I don't like "easy"-syntax languages like Go. I see it is of value for big treadmill-code-machines like google. They want every codemonkey to be easily replaceable. But for me code is also art and fun. I align my assignments and statements and I use different code-formattings according to the situation. If I do all right I only write the code once but read it again and again for years. So I like to spend some time to format my code nicely, whatever that means :-) Writing a code formatter is a fun challenge and sometimes its useful to have a good formatter but please not in my day-to-day job.
- klodolph 7y agoYou can dislike auto code formatting without disparaging people.
- jackewiehose 7y ago?? You mean the word "codemonkey"? That was meant from the employers point of view. I'm a codemonkey myself...
- klodolph 7y agoI’m not a 1980s network censor chasing after “bad words” here. You painted a nasty picture of a company and its relationship with its employees. You can express yourself without attacks.
- deleted 7y ago[deleted]
- jackewiehose 7y agoI don't see it that way. I think I just painted a picture of reality. I didn't even mean to say this behavior is bad.
- asdfasgasdgasdg 7y ago
- andreareina 7y agoExcept for when they make the code harder to read, as black does with a decent chunk of pandas idioms.