News for hackers. Stuff that matters.
Re:My least favorite Rust type by ShroudedNight on Monday September 21, 2020 @05:38PM (#24548767)
Range's idiosyncrasies and the antipathy to improving its ergonomics manifest in the issues raised against the project have been a capstone mental block to my investing emotionally in Rust.

I continuously really want to like the language. The premise is good, a lot of the ideas are really compelling, but when it comes down to aspects I disagree with, I get a strong sense of Rust demanding that users subjugate themselves to all the choices and opinions of the architects, and is (are?) hostile to the notion of a user expressing themselves through their tools, and not just their output. As a result, every time I interact with Rust my hackles end up getting raised and so far it would seem that a (currently absent) existential motivator would be required for me to get past it.

Re:My least favorite Rust type by jdub on Monday September 21, 2020 @10:57PM (#24550436)
This is very far away from the Rust I know, both language and contributors.

Since 1.0 Rust has improved a lot while maintaining compatibility, even through a big deprecation step like the 2018 edition.

A good chunk of those improvements are about making Rust more usable and more forgiving. Some were things I didn't initially recognise as usability problems, but what came out the other side was absolutely better – the modules changes are a good example.

Rust's lead contributors have been welcoming and humble – while also being human. It can be very frustrating running an open source project, and Rust is trying very hard to be open and inclusive, which increases the challenge.

When writing Rust, there are definitely paths of least resistance. You often read about the moment people realise they're going "against the grain", and discovering why it's safar and/or faster to do it "the Rust way". But that's not subjugation. It's about understanding your tools, how they work, and what they're for.

Re:My least favorite Rust type by coolreader18 on Monday September 21, 2020 @07:59PM (#24549635)
> I get a strong sense of Rust demanding that users subjugate themselves to all the choices and opinions of the architects [..]

I don't really get where you're coming from here, especially with regards to this issue -- it seems like almost everyone, including Rust core team members, agree that `impl Iterator for Range` was an API design mistake, that came out of (IIRC) Iterator existing prior to IntoIterator in the pre-1.0 days. This seems to me to just be an unfixable design flaw due to backwards-compatibility rules, not something that really speaks to the design of the language as a whole.

Re:My least favorite Rust type by carlmr on Tuesday September 22, 2020 @04:29AM (#24552223)
>This seems to me to just be an unfixable design flaw due to backwards-compatibility rules

This sounds like something that could be solved in the next edition.

Re:My least favorite Rust type by timClicks on Tuesday September 22, 2020 @05:33AM (#24552586)
How?
Re:My least favorite Rust type by floatboth on Tuesday September 22, 2020 @06:36AM (#24552930)
Make the (x..y) syntax construct some std::BetterRange for code in a new edition.
Re:My least favorite Rust type by timClicks on Wednesday September 23, 2020 @06:14AM (#24565188)
But wouldn't that lead to backwards incompatibilities?
Re:My least favorite Rust type by thayne on Monday September 21, 2020 @10:29PM (#24550306)
> I get a strong sense of Rust demanding that users subjugate themselves to all the choices and opinions of the architects

I don't know why you feel that way. Any major language or standard library change goes through an RFC process, where anyone in the community can submit feedback, and from what I have seen, the official teams are very responsive to concerns.

Re:My least favorite Rust type by ShroudedNight on Tuesday September 22, 2020 @02:22AM (#24551491)
There are a few things:

- The big one is that, at least what I see from my admittedly flawed perspective, there appears to be an active annoyance by a significant number of participants on the various issues on the importance of maintaining library ergonomics under constrained execution environments, with bare metal / free-standing environments being an obvious scenario. An example that comes to mind being stuff dealing with situations where 'global allocation' is actively harmful, which, in addition to happening in kernel development, also happens when building managed runtimes.

- What comes across as an almost begrudging foreign-function interface, no ABI commitments, and lack of clarity about what is undefined behaviour under the `unsafe` operation needed to engage in any of this

- Cargo VS rustc and integration into other build systems. Sanctioned VS unsanctioned paths more generally.

- Prominent people in the community making comments about actively suppressing individual stylistic preferences because it's better for the collective

Re:My least favorite Rust type by ChrisSD on Tuesday September 22, 2020 @04:52AM (#24552344)
That last one is a common enough idea nowadays. Prominent people in every community advocate enforcing code style rules (Douglas Crawford's Javascript linter is famous as an early example and gofmt is practically enforced in the community).

The rest of the issues you mentioned are being actively worked on or investigated. Yes Rust 1.0 didn't solve all problems out of the gate and even now there's a lot of work still to do. But a lot of progress has been made and is being made.

I get that if you don't follow issues, working groups, zulip chats, etc that it may not be obvious what is and isn't being worked on but I'm really not sure where you're getting this "arrogance" from.

Re:My least favorite Rust type by phaylon on Tuesday September 22, 2020 @01:54PM (#24557694)
> That last one is a common enough idea nowadays. Prominent people in every community advocate enforcing code style rules (Douglas Crawford's Javascript linter is famous as an early example and gofmt is practically enforced in the community).

I would argue that this is because there are differences in the severity of the tooling. gofmt for example will not override your decisions regarding line breaks last time I checked, while rustfmt will not afford you any freedoms there.

Re:My least favorite Rust type by thayne on Tuesday September 22, 2020 @02:19PM (#24558031)
> there appears to be an active annoyance by a significant number of participants on the various issues on the importance of maintaining library ergonomics under constrained execution environments

My understanding is that this is being worked on. Of course any language (or really any project) will have people annoyed that the maintainers priorities don't align perfectly with their priorities.

> What comes across as an almost begrudging foreign-function interface,

I haven't gotten any impression that FFI is begrudging. It really seems like a first class citizen to me, and is certainly better than the FFI story in say, java or go. Rust even has language features that exist just for FFI, such as unions and c-style variadic arguments.

> no ABI commitments

This is a recognized problem. It is also a hard problem, since lifetimes don't exist after compile time. But using the C-ABI is quite usable in some cases. And there have been a few RFCs around this recently (specifically around stable ABIs for vtables).

> lack of clarity about what is undefined behaviour under the `unsafe` operation needed to engage in any of this

This is again a known problem, and something that is improving.

> Cargo VS rustc and integration into other build systems.

I think there was some work being done on this, but I don't know the current status. There are people that use rust with bazel.

Re:My least favorite Rust type by Ygg2 on Monday September 21, 2020 @06:57PM (#24549304)
Sure. But to solve those idiosyncrasies, you need to abandon backwards compatibility or introduce conflicting syntax.
Re:My least favorite Rust type by thayne on Monday September 21, 2020 @10:37PM (#24550345)
Not necessarily. A new type could be introduced and the old one deprecated.

Even without introducing a new type, it could be improved in a backwards compatible way. For example, derive the Copy trait, and add a contains method that takes an owned value instead of a reference (at least as long as the Idx type is Copy).

Re:My least favorite Rust type by Ygg2 on Tuesday September 22, 2020 @02:27AM (#24551511)
Pretty sure they discussed this change on Reddit (https://www.reddit.com/r/rust/comments/ix751t/my_least_favor...):

Here is the discussion

      >  In 2021 edition the compiler team could change the 
      meaning of (3..5) to resolve to a new type. Then if you wanted
      the old type you have to request it by a fully qualified name 
      or something.
And the responses was:

      > That would be pretty awful. I think it would be 
      better to change IntoIterator and warn for differences 
      in copy and intoiterator in both editions so you can write portable code.
Re:My least favorite Rust type by TillE on Monday September 21, 2020 @07:41PM (#24549547)
I was super excited about the idea of Rust but constantly frustrated trying to use it to write real code.

I've basically decided to stay in my (ever-improving) comfort zone of C++ until Rust gets named/default arguments, which is my arbitrary litmus test for whether it's going to actually be a usable language for me.

Re:My least favorite Rust type by lalaithion on Monday September 21, 2020 @11:46PM (#24550638)
Not exactly what you want, but one option is to do something like:

    struct OptionsStruct {...}

    impl Default for OptionsStruct {...}

    impl Add for OptionsStruct {...}

    fn port(portnum : u16) -> OptionsStruct {...}
    fn timeout(millis: u64) -> OptionsStruct {...}
    fn maxconns(conns: usize) -> OptionsStruct {...}

    fn main() {
      ...
      // startServer("localhost", default())
      startServer("localhost", port(54321) + timeout(1000));
      ...
    }
Not the most ergonomic, I know, and requires custom architecting for each instance of this, but somewhat doable.
Re:My least favorite Rust type by svnpenn on Monday September 21, 2020 @08:18PM (#24549722)
You can do that now. Its not quite the same but pretty close:

    fn f(n: Option<u8>) -> u8 {
       match n {
          Some(n0) => n0,
          None => 10
       }
    }
    fn main() {
       let n1 = f(Some(20));
       let n2 = f(None);
       println!("{} {}", n1, n2);
    }
Re:My least favorite Rust type by djur on Monday September 21, 2020 @08:35PM (#24549795)
This doesn't demonstrate either named or default arguments. You can expand on it to implement the equivalent of default arguments, sure, but it doesn't solve the ergonomic reason to have default arguments, and it doesn't touch on named arguments at all.
Re:My least favorite Rust type by _28jh on Monday September 21, 2020 @10:36PM (#24550337)
You're missing the point. Here's a good article that talks about the problems of having neither overloading nor default parameters, but in Go.[1] The problem is made significantly worse in Rust when all struct fields need to be initialized and there are no varargs. I really see no solution to the "stable API with more options" problem in Rust, aside from a builder pattern, which I really hate.

1: https://dave.cheney.net/2014/10/17/functional-options-for-fr...

Re:My least favorite Rust type by estebank on Tuesday September 22, 2020 @12:08AM (#24550736)
Why do you have the builder pattern (other than the verbosity of declaring them)?

I normally just leverage a couple of features: Derive(default) to have an "empty" initialized value and the struct field filling syntax

  let x = Foo { field_i_care_about, ..Default::default() };
Re:My least favorite Rust type by svnpenn on Monday September 21, 2020 @11:45PM (#24550629)
In Go, you can use an interface to implement private struct fields. Then you can make a "New" function to implement default values as needed. I made a post about this last month:

https://stackoverflow.com/a/63552596

Re:My least favorite Rust type by fluffything on Tuesday September 22, 2020 @03:39AM (#24551931)
> Range's idiosyncrasies and the antipathy to improving its ergonomics

Can you point us to where this antipathy was displayed?

Re:My least favorite Rust type by jswizzy on Tuesday September 22, 2020 @07:33AM (#24553292)
I've always seen Rust as a transitional language like SmallTalk or ALGOL. It's a glance into the future of programming and the Next era of modern languages but probably not the next 40 year language itself.
Re:My least favorite Rust type by higerordermap on Monday September 21, 2020 @11:29PM (#24550556)
I see scope creep. I don't think it will be very suitable for quick get-webshit-done tasks because of its goals ans design, and they should focus on systems / high performance programming, like zig is doing.