Live data from Hacker News

First Impressions of Rust

john-millikin.com

161–170 of 191 posts

Re: First Impressions of Rust

#161

Yes thank you for not fauning over Cargo like many other reviews. The simple fact is Cargo did not learn from prior art to the extent Rust did. Things have gotten better, but Rust is still better designed. Hopefully Cargo can someday catch up.

I would be curious to hear what are your criticisms of cargo, too. Recently I am trying to study about dependency management in different languages, and cargo, along with bundler seems to be praised quite a bit. I can't correlate it with quality because both rust and ruby camps are quite vocal.

Re: First Impressions of Rust

#162
post #98

> it doesn't even properly align the parenthesized expression after line-breaking it: Fair enough if that's not your preference for how parenthesized expressions should be broken across lines, but this quote makes it seem like it's objectively wrong. In fact it's very much a matter of opinion, and personally I hate the style of line breaking that he describes as "properly" aligned because you end up with a distractin…

This was the key line: > I eventually gave up on trying to make the formatted rust-fuse code look pretty, and settled for "consistent". It turns out that most aspects of coding style are subjective and are fine once you get used to them. The *-fmt tools that are now the fashion get everyone past that initial stage of formatting things as you personally would and get you used to a common style. Maybe one person (the a…

This taboo of having opinions about code formatting shuts down legitimate criticism of rustfmt's design and implementation.

There are cases where rustfmt is just bad. I'd argue "objectively" bad:

• match arms are formatted individually, so nearly-identical arms can end up looking wildly differently if they hit different fuzzy logic thresholds. In Rust, enum variants aren't types, and macros can't see enum variants in the match context, so repetitive match arms are sometimes a necessary evil.

• deletion of a line can fold a multi-line construct into a single line. This makes diffs bigger and harder to review.

• rustfmt throws away any human influence on layout of code (short of sorting functions alphabetically). It doesn't merely change the boring bikeshedable mechanics like where the spaces go, but significantly rearranges how expressions are laid out and separated from each other.

For example:

    let value = do().something().to().get().a_value_maybe()   
       .or_else(|| some_error_handling_here)?;
I think the code above is great, because the happy path is on one line, and error handling is on the other. Rustfmt intentionally erases that:

    let value = 
        do().something().to().get().a_value_maybe().or_else(|| some_error_handling_here)?;
That is IMHO bizarre. The value is what? Oh, there's spaghetti in the second line.

Gofmt is way better. It fixes formatting errors it understands, but when there are multiple correct ways to format a piece of code, it leaves the higher-level structure as-is. OTOH Rustfmt has an overriding opinion on everything. Non-negotiable heuristics replace all common sense.

There's no other production-quality formatter for Rust, so usage of rustfmt boils down to:

1. We must use something 2. Rustfmt is something 3. Therefore, we must use rustfmt

Re: First Impressions of Rust

#163
post #44

> I eventually gave up on trying to make the formatted rust-fuse code look pretty, and settled for "consistent". Even though it's a bit ugly, this is a big win. As for why it does this, from my experience, rust-fmt will try to keep lines under a column limit but not greedily. e.g. if a params list would extend past the limit, then all params get a newline. It seems to try to balance horizontal estate and vertical est…

What's more important IMO is the erasure of time & mental overhead that are normally spent formatting. Formatting is (broadly) a giant waste of time. I honestly do not care if the result is ugly. And that ignores the synergistic benefits of erasing all style-based co-ordination problems & arguments & bikeshedding & whatever else from the entire codebase. IMO it's a no-brainer.

> erasing all style-based co-ordination problems & arguments & bikeshedding & whatever else from the entire codebase.

Exactly this. I sat across from the poor soul who was assigned to creating the coding standards for our C# stuff. It tooks months. Nobody was happy, everyone had their own way of doing things: var vs. no-var vs. obvious-type-var, CONST_VALUE vs ConstValue. The work has been completed (the person in question quit soon after), people are still unhappy, there are still (and will always be) open questions. People nit coding standards in code reviews instead of looking for real issues. What a shitshow. If you remove autonomy concerning coding standards from the get-go, people never form these opinions.

If code is not optimally pretty, that sucks. Establishing coding standards is an bottomless pit of despair. Almost any opinionated formatter is worlds better than the worthless sisyphian task of establishing your own coding standards.

Re: First Impressions of Rust

#164
post #99
post #23

I find it absolutely frustrating that Rust packaging/crates.io doesn't support namespaces. The arguments I've read are always theoretical/what ifs, but I've yet to be convinced the current situation is better than the practical benefits of namespaces.

Everyone complains that 'fuse' is taken so they have to use something with qualifiers (e.g. rust-fuse), and then they propose to fix this with a solution that requires that everyone uses qualifiers for everything . It's a bit more consistent in that no-one gets good names, but is it really such a problem that a few people happened to get in early enough that they could call their library 'fuse'?

Names can be powerful. Owning a name like "fuse" implies that this is the thing called "fuse".

A flat "top level" namespace encourages treating names, especially short names, as something with intrinsic value. You end up with the same problems that the .com namespace has, such as name squatting and first mover advantage.

Qualifying all names removes this property from names and levels the playing field. There's no value in "owning" github.com/somename/blah. Or, to take the NPM approach, @somename/blah.

Re: First Impressions of Rust

#165
> I've found Bazel and rules_rust provide a good alternative to Cargo, since Bazel can twist your build into any DAG you want, but most Rust users are unlikely to be excited about injecting 50MB of Java build system into the middle of their workflow.

If anyone is interested in another alternative to Cargo that doesn't involve Java, there is build2[1] and it's libbuild2-rust[2] module. It's a general-purpose build system so you can have mixed-language projects, etc.

[1] https://build2.org

[2] https://github.com/build2/libbuild2-rust

Re: First Impressions of Rust

#166

Earlier quoted context omitted.

Conversely the arguments I've heard for namespaces is that multiple people want to reimplement or make bindings for the same C library. In maven central, in my anecdotal experience, namespaces usually either distinguish forks of the same library, or to group related libraries. There has never been, in my experience, a case where I wanted two packages with the same name in different namespaces. I think a better system…

Of course a single project is very unlikely to depend on two different packages with the same name. But a global repository of all packages is conversely extremely likely to have many many people all wanting one name - it's essentially a .com registry. Reusing project names is just a straight no-go when that is what other peoples projects depend on. As soon as a package has a dependency, (name, version, source) need…

As the person you are replying to suggestes, a version epoch could be a solution.

Re: First Impressions of Rust

#167
post #99

Earlier quoted context omitted.

Everyone complains that 'fuse' is taken so they have to use something with qualifiers (e.g. rust-fuse), and then they propose to fix this with a solution that requires that everyone uses qualifiers for everything . It's a bit more consistent in that no-one gets good names, but is it really such a problem that a few people happened to get in early enough that they could call their library 'fuse'?

Names can be powerful. Owning a name like "fuse" implies that this is the thing called "fuse". A flat "top level" namespace encourages treating names, especially short names, as something with intrinsic value. You end up with the same problems that the .com namespace has, such as name squatting and first mover advantage. Qualifying all names removes this property from names and levels the playing field. There's no va…

But then everyone just wants @fuse/fuse rather than fuse. If one project is @fuse/fuse and the other is @atombender/fuse, the first is going to have more legitimacy, just as if they were called fuse and atombender-fuse.

Re: First Impressions of Rust

#168

Earlier quoted context omitted.

Thinking about it, you're probably right. One thing you're missing for your comment is different field name lengths, which is important because you seem to care about alignment of field values: field1: 1 this_is_a_longer_field: 2 Playing with rustfmt online [1], I found that by default it doesn't do that: field1: 1 this_is_a_longer_field: 2 As a sibling comment says, you must have an option turned on an option for th…

> You've presumably also got an option turned on for > tabs. I honestly think that is quite a niche > preference nowadays gofmt always indents with tabs, so I'd argue that it's not _that_ niche. One might also argue that, as a zero-cost abstraction for consistently applying a developer's preferred indent depth, they are the most Rust-appropriate option . > Once the formatter has (incorrectly, you argue) decided > to…

> A lot of very old indenters will treat tabs and spaces as interchangeable, ….

Indeed. If you're going to align expressions in a file that uses tabs for indentation then you need to use tabs up to the block indentation level, but spaces after that for the alignment. That's the only way to ensure that the lines continue to be aligned for any tab-stop setting. Many editors will mangle this horribly, however, by replacing some or all of the spaces with tabs. If you're using tabs for indentation then you really need to turn on visible whitespace and also disable automatic conversion of spaces to tabs unless you're sure your editor is one of the few that gets it right.

Re: First Impressions of Rust

#169
post #136

Earlier quoted context omitted.

I'm fine with qualifiers, but I don't want useless qualifiers. "rust-" or "-rs" is useless because it's on crates.io. "lib" or "-lib" similarly, unless it's part of a pair with a binary of the same name. Here's a partial list of FUSE server implementations on crates.io: * fuse * cntr-fuse * drakey-fuse * fuse_mt * fuser * fuse-rs * polyfuse * fuse3 * yarf Why do we make people come up with custom prefixes or opaque c…

Why not user-fuse?

[deleted]

Re: First Impressions of Rust

#170

Earlier quoted context omitted.

I don't like either of these. Keep it all on one line.

You mean never wrap code and have a really long horizontal scroll? These things are subjective and you're certainly entitled to your opinion, but is say that's fairly hardcore.

You could let the editor soft-wrap the lines in place of horizontal scroll. Done well this could be the best of both worlds—adaptive to different screen/editor sizes, and the viewer decides how to indent or align the wrapped lines according to their own preferences. However, proper expression alignment would require solid language support from the editor. (Wrapping with simple indentation wouldn't be too difficult.)
Post reply on HN