News for hackers. Stuff that matters.
Re:Rust can be difficult to learn and frustrating, but it's ... by carlmr on Tuesday October 23, 2018 @03:15AM (#18281374)
>Bur honestly, the syntax is gruesome. Coming from Python, Rust looks like two rabid gerbils had a war dance on my keyboard.

What exactly is terrible about it? The snake_case I got used to, I kind of like having braces, and that's not really a killer argument either, because most languages have them, apart from that I find Rust also much cleaner than Python syntax. I'm really not sure what you mean. Is it the lifetime annotations (because they're somewhat necessary).

Re:Rust can be difficult to learn and frustrating, but it's ... by iopq on Tuesday October 23, 2018 @04:36AM (#18281747)
Okay, tell me if this is readable to you:

   fn accumulate<'a, T: Monoid>(tuples: &[(&'a str, &Fn(i32) -> bool)], i: i32) -> T
   where
        T: From<&'a str> + From<String>,
this is JUST the function signature

yes, every single thing in there is necessary, it can be written in a more gruesome way, but the where clause clarifies it a bit

But let me cheat a little bit

    ( $(#[$attr:meta])* enum $enumer:ident { $($i:ident => $e:tt $( ( $($m:ident),* ) )* ; )* } ) => {
how is this macro syntax looking?
Re:Rust can be difficult to learn and frustrating, but it's ... by carlmr on Tuesday October 23, 2018 @04:44AM (#18281777)
#1 I find is not worse than C++, granted there's more complexity here than in Python but in terms of cleanness its ok IMHO. Because as you said there's nothing unnecessary. Rust addresses different problems than Python, so we should compare apples with apples.

On the second one you got me though, I find the macro syntax a bit horrible. Sometimes I just want simple text substitution.

Re:Rust can be difficult to learn and frustrating, but it's ... by iopq on Tuesday October 23, 2018 @06:24AM (#18282180)
I'm comparing it to Haskell syntax for the same thing, which is much cleaner
Re:Rust can be difficult to learn and frustrating, but it's ... by olavk on Tuesday October 23, 2018 @06:47AM (#18282269)
Haskell does not have borrowing and lifetime specifiers though, which is what makes the Rust example more dense.
Re:Rust can be difficult to learn and frustrating, but it's ... by iopq on Tuesday October 23, 2018 @11:02AM (#18283941)
Haskell has nice syntax for generics, no stupid <> to forward declare type parameters
Re:Rust can be difficult to learn and frustrating, but it's ... by User23 on Tuesday October 23, 2018 @06:44AM (#18282256)
C++ templates also aren't winning any readability awards.
Re:Rust can be difficult to learn and frustrating, but it's ... by olavk on Tuesday October 23, 2018 @06:46AM (#18282264)
It is somewhat unfair to compare this to Python, since a lot of the simplicity in Python comes from the semantics (dynamically typed, garbage collected and so on). Rust need to express all this information (types, lifetimes etc.), so it will necessarily be more dense. The question is if this information could be expressed in a more readable syntax. This might be possible, but I would like to see a suggestion of how.

I guess the signature could be made more readable by using a few type aliases. The hardest part to read is the nested types.

I'm with you on the macro syntax, it is very hard to read. It is not easy to create a readable macro syntax though. All languages I know have hard-to-read macros, so this is not yet a solved problem.

Re:Rust can be difficult to learn and frustrating, but it's ... by iopq on Tuesday October 23, 2018 @11:17AM (#18284068)
Here is a simpler syntax:

   fn accumulate tuples: &[(&'a Str, &Fn(i32) -> Bool)], i: i32 -> t
   where
        t: Monoid + From &'a Str + From String,
this is how Haskell with lifetimes and borrowing would look like (if arguments were not curried)
Re:Rust can be difficult to learn and frustrating, but it's ... by Rusky on Tuesday October 23, 2018 @07:46PM (#18288484)
This is arguably less readable, because it's missing some delimiters for your eyes to latch onto.

It's also not realistically parseable- the Haskell/Ocaml-like removal of <>s and ()s relies on application being left-associative, and if you read this under that rule you've changed the meaning (e.g. `From &'a Str`).

Re:Rust can be difficult to learn and frustrating, but it's ... by olavk on Wednesday October 24, 2018 @06:31AM (#18291153)
I like removing superfluous punctuation, but if parentheses are removed from method signatures than they should also be removed from invocations, which in turn comes with its own set of readability issues. I'm not a fan of the $ operator in Haskell, for example.
Re:Rust can be difficult to learn and frustrating, but it's ... by antaviana on Tuesday October 23, 2018 @09:02AM (#18282965)
This also reminds me that, in Python 2.x, the following code...

for i in range(100000000):

...creates in memory a list with one-hundred million integers.

Expressive yes, but sometimes it can be double-edged for new comers (and not new comers).

Re:Rust can be difficult to learn and frustrating, but it's ... by nchie on Tuesday October 23, 2018 @04:06AM (#18281600)
As someone with a C++ background who loves Rust and wants it to succeed: Code where the lifetime syntax is used much can look really horrible and confusing, and to people new to Rust it might feel like it's for no reason.