News for hackers. Stuff that matters.
Re:The Bastion of the Turbofish by maxroverts on Thursday January 07, 2021 @05:51PM (#25678786)
Is it really that hard to parse generics without a 'turbofish'? Coming from Scala and Haskell something like:

Into::<String>::into()

Just really irks me. It is much less elegant than I am used to. Do experienced Rust developers actually like the style, or is it just complex to parse?

Re:The Bastion of the Turbofish by steveklabnik on Thursday January 07, 2021 @06:23PM (#25679078)
You need it very rarely, so it’s just really a non-issue. Like, you don’t even have to use it in many cases where you could. For example, this case doesn’t have to use the turbo fish.

I don’t think the turbo fish is particularly good looking, but it is better than the alternatives, and something I rarely even need to see, let alone write.

Re:The Bastion of the Turbofish by mickallen on Thursday January 07, 2021 @06:16PM (#25679005)
I personally have no issue with it. Because Rust's type inference is so good, you don't generally even have to specify generic type parameters for method calls. It is more verbose and perhaps you could say less elegant, but I think it better expresses the concept.
Re:The Bastion of the Turbofish by rbanfyy on Thursday January 07, 2021 @06:13PM (#25678972)
Rust is the most unreadable language that I've tried. I really wanted to like it but everything is just so ugly and unnecessarily complicated. The turbofish reflects that.
Re:The Bastion of the Turbofish by ibraheemdev on Thursday January 07, 2021 @06:20PM (#25679054)
Could you expand on this? I have heard many people say Rust is 'ugly', but I personally have no issue with it.
Re:The Bastion of the Turbofish by fransiscoli on Thursday January 07, 2021 @06:42PM (#25679273)
I think lifetimes are the part of Rust that people see as ugly. I recently wrote the following lines of code:

  struct Parser<'a, 'b, T> {
      value: &'a [T],
      inner: InnerParser<'a, 'b>
  }

  impl<'a, 'b, T> for Parser<'a, 'b, T> {
      fn parse<T: Into<String>>(value: T) -> &'static str {
          ...
      }
  }
and the equivalent code in Scala:

  class Parser[T] {
    var value: List[A] = Nil
    var inner: InnerParser = Nil

    def parse(value: String): String = ...
  }
of course, those programs are not semantically equivalent, but you can clearly see that the Scala version is the more elegant of the two. I can't think of any other way that you could syntactically express lifetimes, but I can see why people would see Rust as ugly.
Re:The Bastion of the Turbofish by drran on Thursday January 07, 2021 @07:36PM (#25679710)
You just cannot write semantically equivalent code in Scala, because it uses the garbage collector.