4 ms·
A lot of the stuff that interests me is how much this focuses on making things automatic. Use compiler plugins to automatically check your code, use rustfmt to
by steveklabnik 11y ago
A lot of the stuff that interests me is how much this focuses on making things automatic. Use compiler plugins to automatically check your code, use rustfmt to automatically reformat your code, use highfive to automatically greet new contributors, use homu to automatically ensure good CI, use Travis to automatically upload docs, etc.
I like things that are automatic. That way, I don't forget about them.
- killercup 11y ago> I like things that are automatic. That way, I don't forget about them. Yes! And that way I don't have to _trust anyone_ (including myself) to remember them. I can't wait for the day where I can safely run clippy on stable and fail my tests when code is formatted incorrectly (according to rustfmt) :)
- Manishearth 11y agoClippy running on stable is quite far off. We've had discussions about stabilizing plugins, but it's not happening soon. Instead, make clippy an optional feature, and compile with `cargo build --features=clippy` on your CI on nightly.
- killercup 11y ago> make clippy an optional feature Yeah, that's what I'm doing but that is also the reason why nightly is an allowed failure on Travis… I have high hopes for compiler plugins after the current internal refactorings (HIR, MIR), though :)
- Manishearth 11y agoHIR/MIR don't really help much, actually. A stable plugin interface would probably be completely different. And clippy uses a _lot_ of internals, so even if a plugin interface stabilizes there's no guarantee clippy will.
- steveklabnik 11y agoMy understanding was that HIR was supposed to _be_ a stable plugin interface.
- Manishearth 11y agoPerhaps. There's still a long way to go though, since you need a stable AST builder or qquote mechanism, among other things. And HIR isn't nearly enough for clippy to work on stable.
- squiguy7 11y agoI agree with this. Having things be automatic and unified is great. If there is a standard that Rust enforces regarding style or lints, then any crate published should be easily read by others interested in contributing. It removes the overhead of having to consider what style the main author used or what lints are in place when compiling it.
- nordsieck 11y agoOne of the things that's had the greatest impact on me is a comment D.J. Bernstein made about writing good software: For more than a decade I have been systematically identifying error-prone programming habits—by reviewing the literature, by analyzing other people’s mistakes, and by analyzing my own mistakes—and redesigning my programming environment to eliminate those habits. http://www.aaronsw.com/weblog/001502 http://www.aaronsw.com/weblog/001502 Given his track record with writing software largely without security defects, this seems like a promising avenue advancement.
- Stratoscope 11y agorustfmt makes me sad. So do the official Rust and Servo style guides. The whitespace style they mandate ("column align all the things!") is wildly impractical. I used to use this exact same style myself, many years ago, but gave it up when I saw how many problems it caused. I'll never go back to this kind of column-aligned formatting. Here's an example from the rustfmt source code: let mut rewrites = try_opt!(subexpr_list.iter() .rev() .map(|e| { rewrite_chain_expr(e, total_span, context, max_width, indent) }) .collect::<Option<Vec<_>>>()); Here's how I would format that code instead: let mut rewrites = try_opt!( subexpr_list .iter() .rev() .map( |e| { rewrite_chain_expr( e, total_span, context, max_width, indent ) }) .collect::<Option<Vec<_>>>() ); Or, perhaps if the variable names in the rewrite_chain_expr() call were a little longer, like this: let mut rewrites = try_opt!( subexpr_list .iter() .rev() .map( |e| { rewrite_chain_expr( e, total_span, context, max_width, indent ) }) .collect::<Option<Vec<_>>>() ); Either way, the difference is that I use indentation everywhere that the rustfmt style uses column alignment. This kind of indentation-based style has numerous advantages over a column-aligned style. I wrote about this at some length previously, so rather than repeat the details, here are my previous comments for anyone who is curious about the rationale for this indentation style: https://news.ycombinator.com/item?id=10206860 https://news.ycombinator.com/item?id=10206860 https://news.ycombinator.com/item?id=9469713 https://news.ycombinator.com/item?id=9469713 Anyway, it isn't the rustfmt style itself that makes me sad. It's the presumption behind these kind of rigid code reformatters. The bottom line seems to be this collection of notions: 1. Consistent code formatting and whitespace style is vitally important. So important that an automated tool is required to insure that there are no variations in formatting. 2. The exact details of how code is formatted don't matter much. Any formatting style is about as good as any other, as long it is 100% consistent within a project (or language, or whatever). A professional programmer should just find out what the standard is and follow it. 3. There is nothing new to be learned in formatting style. The way we've always done it is good enough, and as good as any other. (See #2.) If you have new and different ideas about whitespace, they are unhelpful and unwelcome. Stop bikeshedding! And that is what makes me sad.