News for hackers. Stuff that matters.
Re:Notes on a Smaller Rust by rishav_sharan on Thursday July 18, 2019 @07:30AM (#20468676)
As someone who recognizes himself as beginner programmer, i do not consider the borrow checker as my major issue with the language. Heck, i haven't even reached that issue.

Everytime that I have turned away from Rust, despite trying half a dozen times is due to its super busy and alien looking syntax. I just can't parse the code.

Re:Notes on a Smaller Rust by pdpi on Thursday July 18, 2019 @08:02AM (#20468865)
Honestly, I don't see any intrinsic problems with Rust's syntax that makes it unusually ugly.

Rather, I think the problem is that the syntax is 100% fine in isolation, but has some issues when taken together with experience in other languages — when you skim the code, some parts of it beg to be looked at like C++, while other parts push you to read it like a functional language. Unsurprisingly, neither fully works, which makes the experience jarring. Once you accept that Rust is its own language with its own rules and stop trying to borrow (hah!) from your experience with other languages, it feels much better.

Re:Notes on a Smaller Rust by sagichmal on Thursday July 18, 2019 @09:23AM (#20469471)
> Honestly, I don't see any intrinsic problems with Rust's syntax that makes it unusually ugly.

You literally just got a user experience report claiming that it is.

Re:Notes on a Smaller Rust by munmaek on Thursday July 18, 2019 @10:05AM (#20469878)
It's coming from someone who isn't comfortable with C or Java either.

There's no winning over everyone. Of course Rust's syntax will be completely jarring if you're coming from Crystal or Ruby.

In my personal experience it's a little jarring at first and then it completely goes away.

Re:Notes on a Smaller Rust by spease on Thursday July 18, 2019 @12:44PM (#20471589)
I’m comfortable with C/++ and Java, to a greater extent than a lot of people I’ve worked with. There are still things in Rust that are papercuts:

* The need to put :: before <> in expressions for generic parameters, but not in type signatures.

* Using :: instead of just . even though most of the time the naming convention will delineate the difference anyway

* Error handling with futures

* Self-referential structs

* Passing a shared pointer through multiple move closures

IMHO the frustration involved in these things is not typically worth being more explicit. The :: thing may seem a bit pedantic, but it is simply more physical effort (Shift-colon-colon vs dot) and creates more visual noise.

If/when all of the things above are addressed, I think Rust could give Python a run for its money.

Re:Notes on a Smaller Rust by guiriduro on Thursday July 18, 2019 @08:48AM (#20469177)
Oh yeah, I totally get that with Nim's * (export symbol), just can't get past my 20 years ago c++ pointer syntax brain wiring, even though I've barely touched it since. Always needs a double-take, which spoils reading flow.
Re:Notes on a Smaller Rust by sixbrx on Thursday July 18, 2019 @11:08AM (#20470592)
Agree and also I think the main issue is that parts of the syntax are pointing to ideas that are not present in common languages, but which are essential in Rust. They aren't merely syntactical choices and can't be papered over or omitted. If you don't want to consider these concerns (like lifetimes) then it's probably not the language for you and changes in syntax won't help (much) there.
Re:Notes on a Smaller Rust by Spartan-S63 on Thursday July 18, 2019 @09:58AM (#20469804)
I had many many false starts back in 2014 when I tried learning Rust. It took me to stop comparing it or thinking about it like C++ (syntactically and semantically) in order for me to get it. Now, I’d consider myself reasonably fluent in Rust.

I don’t mind the syntax because I find it explicit enough, but terse enough in certain cases. It’s similar but different and so it rhymes with my past in C++, but it’s not the same.

Re:Notes on a Smaller Rust by paavohtl on Thursday July 18, 2019 @07:46AM (#20468750)
What other languages do you have experience with? IMO the syntax is not wildly different from other statically typed curly bracket languages. IMO the most alien thing it has in terms of syntax is the use of a single quote for lifetime parameters ('a), but even that is based on the type parameter syntax for already existing languages (OCaml, F#, Standard ML).
Re:Notes on a Smaller Rust by rishav_sharan on Thursday July 18, 2019 @09:26AM (#20469499)
Crystal and vanilla es6 are my favoured languages. I also adore elixir. I have recently done some toy projects in f# using xelmish. I have written small projects in python, nodejs and lua. I have also tried Nim and wren. So while i am not much of a programmer, I love trying new languages. Out of all the languages that I tried, Rust and lisp are the two which scared me off outright just based on the syntax
Re:Notes on a Smaller Rust by leshow on Thursday July 18, 2019 @09:47AM (#20469703)
I don't see where you're coming from honestly. It has familiar C-style syntax, it has type parameters in the form java does with <>.
Re:Notes on a Smaller Rust by rishav_sharan on Thursday July 18, 2019 @09:54AM (#20469773)
Seeing my own list, i don't think i am comfortable with either c or java. So that's probably why. C, java, c++ are other notable languages i never could get into.
Re:Notes on a Smaller Rust by leshow on Thursday July 18, 2019 @03:48PM (#20473302)
javascript also has C style syntax, which you claimed to be familiar with. It's subjective, so I can't say that you're wrong. I just don't get it.
Re:Notes on a Smaller Rust by skohan on Thursday July 18, 2019 @10:46AM (#20470351)
Honestly I have a hard time understanding why you're being downvoted for expressing an opinion.
Re:Notes on a Smaller Rust by MrBuddyCasino on Thursday July 18, 2019 @07:53AM (#20468806)
Rust is unpleasant to look at. I know its silly, but that my biggest gripe with it as well, aside from sometimes overly complex type signatures due to generics. As a reference, I consider Python and Kotlin to be a e s t e t i c.
Re:Notes on a Smaller Rust by adestefan on Thursday July 18, 2019 @08:14AM (#20468948)
What was the first programming language you really understood and learned? I ask because most of the time people think something different is complex or "ugly" it's because they're using bad abstractions between what they fully understood first to other things they think is in the same domain.

Patricia Asa has an excellent presentation[0] on how she tried to learned C# and one of the biggest things she discovered was these bad cross-over abstractions held her back.

[0] https://www.youtube.com/watch?v=Id2jBMJLz2Y

Re:Notes on a Smaller Rust by clinta on Thursday July 18, 2019 @09:44AM (#20469671)
My first programming language was Python. And now I write Python and Go frequently.

I'm trying to learn Rust, working through various programming exercises, but it looks and feels very foreign to me.

One example is the closure syntax. Compared to Go where closures look just like function definitions, closures in Rust look needlessly complex.

I also always find myself wanting to type mut &a instead of the correct &mut a. The former just seems more obvious to me, a reference to a is &a. Mutable a is mut a. So a mutable reference must be mut &a.

Then the lifetime syntax, I don't even know what to think of that, but that's probably more because I'm struggling asking myself "Should I use a lifetime here, or am I doing something else wrong that is preventing the compiler from figuring it out."

Maybe these things make more sense to people coming from C.

Re:Notes on a Smaller Rust by steveklabnik on Thursday July 18, 2019 @10:21AM (#20470049)
We took the closure syntax from Ruby/Smalltalk, and the lifetime syntax from OCaml.
Re:Notes on a Smaller Rust by dastbe on Thursday July 18, 2019 @11:10AM (#20470623)
On &mut a vs. mut &a, when read literally left to right the former is “a reference to a mutable a” and the latter is “a mutable reference to a”
Re:Notes on a Smaller Rust by swsieber on Thursday July 18, 2019 @10:21AM (#20470043)
I'm guessing the &mut a stuff makes more sense to C folks. In C you have to deal with const, and it can go anywhere. A const pointer to a non-const item, a pointer to const value, etc. That's my guess anyway.
Re:Notes on a Smaller Rust by MrBuddyCasino on Thursday July 18, 2019 @04:10PM (#20473489)
For the record, I consider Clojure to be beautiful as well, in its own way.
Re:Notes on a Smaller Rust by skohan on Thursday July 18, 2019 @09:15AM (#20469412)
I had experience somewhat counter to this. I learned C and C++ first, and when I first started working with Java things like CamelCase did seem a bit strange and off-putting to me, but I got used to the less keystrokes surprisingly quickly, and it's one of the things which bothers me most about working with Rust.

I think there is such a thing as liking what's familiar, but there are also design decisions which are simply easier to read or easier to parse. Another one would be semicolons: I have never missed semicolons one bit in a language where they're not required.

Re:Notes on a Smaller Rust by kybernetikos on Thursday July 18, 2019 @10:11AM (#20469941)
> I have never missed semicolons one bit in a language where they're not required.

I dutifully wrote semicolons for years, but just a short stint of Scala and I don't like using them anywhere now.

Re:Notes on a Smaller Rust by lloydatkinson on Thursday July 18, 2019 @08:17AM (#20468966)
I have the same experience - I don't know what the hell is going on in the code with Rust. Compared to say F#, its far more verbose and feels too much like C++.

In the same vein I think Typescript error messages are absolutely horrific. Furthermore, I keep seeing people who start using Typescript to "make it like my preferred language xyz".

Coincidentally these devs 1) hate Javascript 2) end up writing a massively over engineered OO big ball of mud

These reasons are why I avoid Typescript where I can.

Re:Notes on a Smaller Rust by slezyr on Thursday July 18, 2019 @07:57AM (#20468837)
And crystal lang, for static typed language example.

https://crystal-lang.org/reference/overview/http_server.html

Re:Notes on a Smaller Rust by skohan on Thursday July 18, 2019 @09:30AM (#20469550)
I'm so not a fan of the ruby-style blocks. I never understood the appeal of typing "end" a million times instead of a single close brace.
Re:Notes on a Smaller Rust by munmaek on Thursday July 18, 2019 @10:10AM (#20469924)
{} blocks are used but for one line methods/closures. Since programming has nothing to do with typing speed, there isn't much difference between `end` and `}` other than `end` making more sense in ruby's english-like syntax.
Re:Notes on a Smaller Rust by skohan on Thursday July 18, 2019 @10:33AM (#20470200)
> Since programming has nothing to do with typing speed

I have heard this a lot, and I am not sure I agree. I agree that the limiting factor for how long a project takes to finish is never going to be how fast you can type, but when I am really in flow I am actually typing pretty quickly, and I don't really like more friction when it's not necessary.

Of course it's a matter of taste, but the argument that it's english-like never made sense to me either. There is no english sentence construct with "do ... end" or "wile ... end".

Re:Notes on a Smaller Rust by leshow on Thursday July 18, 2019 @03:53PM (#20473345)
The problem with 'end' IMO is that you have to actually read the word, with } you don't. Of course, this is all useless to argue about. I quite like that lots of languages look different.
Re:Notes on a Smaller Rust by _bxg1 on Thursday July 18, 2019 @09:40AM (#20469629)
Maybe it's my background (Java and JS with a little bit of C++), but I don't find it alien at all. I do find it really clunky in a handful of situations, mostly having to do with lots of nested containers (Option<Arc<Box<...), but luckily those are uncommon for most use-cases.
Re:Notes on a Smaller Rust by skohan on Thursday July 18, 2019 @10:50AM (#20470395)
The bit which seems the most cumbersome to me is working with things like str/String and Path - it seems like there's always a lot of finagling and long chains of method calls to get things into the right type representation for a particular use-case.

I'm still not so experienced though so maybe it gets better.

Re:Notes on a Smaller Rust by _bxg1 on Thursday July 18, 2019 @11:03AM (#20470543)
I think what helps with that is building up a mental model of where things actually live in memory. If you create a new String, you're putting it on the heap. Which makes sense, because strings can be of any arbitrary length. It also makes sense, then, that you can mutate these heap-strings, because they have room to grow. In contrast, the only strings that can go on the stack (so you don't need String::new) are ones whose lengths are known at compile-time. So, a string literal (str).

There are many things like this in Rust where if you just follow the compiler errors until you can make it happy, things will end up really convoluted and baffling. They'll also probably not perform as well. To really use Rust you have to absorb what's actually going on underneath its protections, and not just the errors that surface from them. This isn't easy, and is probably the dividing line between people who stick with it and people who decide it's not for them.

You get about 50% of this picture for free (thinking in terms of stack, heap, references) if you've done C/C++ before. The other 50% is completely unique to Rust. But the key is to read the Book, follow guides, etc. Rust isn't really something you can learn just by hacking it out on your own, unfortunately.