8 ms·
The one thing that would put rust over the top right now is something along the lines of gofmt - something simple, with zero configuration, that can be run on c
by TylerE 12y ago
The one thing that would put rust over the top right now is something along the lines of gofmt - something simple, with zero configuration, that can be run on commit or even save.
- steveklabnik 12y agoWe absolutely want one, but we've been actually developing the conventions first. You have to know what you want to format to!
- gthank 12y agoPlease tell me those discussions are on the mailing list.
- steveklabnik 12y agoThey're actually RFCs. And the results are in a repository. I'm on mobile or I'd link you. But they generally codify already-existing style, rather than mandating it, although sometimes we just need a decision to tear down a bikeshed...
- pselbert 12y agoI was on the rust mailing list for a little while about a year ago. Around that time there was discussion of this exact subject. Most of the discussion was around exactly how to break parameters beyond a certain length and so forth, but it was there.
- deleted 12y ago[deleted]
- 2mur 12y agogofmt is a huge win for Go. Bye bye bikeshedding. I'd love to see that for Rust too.
- mhd 12y agoindent(1) has been around for ages. Where does this sudden need for universal style goose stepping come from?
- esrauch 12y ago1) A lot more code isn't read in vim or emacs nowadays. We don't have the equivalent of indent on the github web ui 2) Everyone and their mother is doing code reviews now, and a lot of code reviews get (very visibly) bogged down by style disputes. 3) indent and his modern friends (eg clang-format) generally only answer trivial whitespace questions, and not even things like method capitalization. gofmt is the obvious extension of indent.
- mhd 12y agoWhether it's called indent, gofmt or Visual Source Formatter 2051 doesn't really change its availability. Nor does it really matter a lot how much of the source is munged -- every forced change is probably annoying to someone. The main issue for me is that your code reviwer isn't looking at the code from my company. So why should I give a damn what they think about how spaces around the parens of a function call should look like in the code I'm editing? I'm not convinced that this should leave the bounds of a project. Within that, sure! Let's put a .rustformat right next to .gitignore, and whatever your source discombobulation utility is called just takes its hint from there. Certainly nothing wrong with a language having a good indenter, doc tool and linter in the core distribution. But one language, one style, one tab width!?! This is especially annoying when you've got a pretty unified style across all other algol-/C-ish languages, yet can't keep this in your newest one. For the sole reason of pleasing some community that'll never see one line of your code.
- TylerE 12y agoI think you're kind of missing the point. The point isn't to have a "house" style, it's to have an "everything" style. Making it optional or configurable defeats the purpose.
- __david__ 12y agoUgh. I hate gofmt. It's a good idea in principle, but even with "go" there are times when you want things spaced out to align columns, or hide a distracting error handling case on one line (instead of making it take 3 lines of precious vertical screen real estate). I find gofmt to be too opinionated about certain things and I will never use it for my go programs.
- ossreality 12y agoShoving stuff on multiple lines to save vertical space is a great way to get into a crappy codebase quickly. Gofmt respects vertical alignment of basically everything I've ever vertically aligned, and it's remarkably intelligent about it in places. >I will never use it for my go programs. And no one will colloborate with you. Look at ANY Go project on Github and the first issue is "run gofmt". It gets rid of entire bike-shedding discussions like this. As an example, comprehensively document in what cases you do and do-not put two lines of code on the same physical line. Now try to enforce that across the entire internet, let alone in a lexing tool.
- ptx 12y agoWhy is it a good idea in principle then? Automatic reformatting of the source code always seemed like a bad idea to me for precisely the sort of reason you describe.
- mhd 12y agoIt's good enough when you can configure it and apply it selectively. If I want to clean up a function in my code base, I can e.g. select it and run "perltidy" over it, which has a configuration dot file for the company code standard (or CPAN guidelines etc.). Or just clean up some nags so that version control behaves better. But if the only option is not running it at all or having all the code automatically fit to whatever the people On High have deemed to be visually pleasing? Yeah...
- flogic 12y agoIt's irksome when the auto formatter does something ugly. Though, I think the issue is far worse with Perl tidy. With, gofmt my view is more "I don't like this bit but fuck it." Probably because, Go has much simpler syntax.
- yazaddaruvala 12y agogofmt is nice. gofix: way more useful!
- gnuvince 12y agoAre you sure you're not exaggerating the benefits of an automatic formatting tool? I'm thinking that a large number of libraries, usage by multiple high-profile companies, a killer app, etc. would be better for Rust at this point.
- hamstergene 12y agoThis makes me thinking, since world of coding has already reached the point of using zero-configuration fully automated code formatting tools on save/commit, why not make the final logical step — enforce coding style by language syntax, and be done with almost all extra burden of coding conventions. Right now almost every company and even separate teams develop their own coding conventions document and configure their tools and infrastructure for it. But if all programmers agree that "coding style does not matter as long as it's consistent" and every one is willing to accept a project's coding style when joining that project, why not pick one style for all and put it into programming languages themselves. I imagine a lot of paperwork and human time would be saved.