News for hackers. Stuff that matters.
Re:Comparing Parallel Rust and C++ by pcwalton on Thursday November 07, 2019 @10:37AM (#21474101)
> I feel like the language designers didn't pay attention at all to how natural it will look to developers

This is not true. We agonized over syntax decisions. "fn" was actually preferred by most of the Rust community.

Re:Comparing Parallel Rust and C++ by jandrese on Thursday November 07, 2019 @01:12PM (#21475674)
I've had the impression that Rust developers come from a more pure-math background than most language designers. People who read mathematical notation all day probably find Rust to be more natural than a typical programming language. For people coming from a traditional computer language background the number of sigils on each line is a point of pain.

IMHO Rust may have tried to roll a little too much into the language. It has the air of the second system effect to it, where every good idea from every language is added together to get something that is less than the sum of its parts and you get code that is hard to decipher until you've learned a full college course worth of syntax.

Re:Comparing Parallel Rust and C++ by pcwalton on Friday November 08, 2019 @12:01AM (#21480073)
I designed the lifetime syntax and I'm far from having a pure math background. There aren't any sigils in Rust that C doesn't have, other than the lifetime syntax, which needs separate syntax as it's a novel feature.

Can you name a specific feature you want removed from Rust?

Re:Comparing Parallel Rust and C++ by jandrese on Friday November 08, 2019 @12:40PM (#21484663)
I'm not sure I'd want it removed, but generics tend to be pretty horrific looking to people new to the language.

An example:

  fn largest<T>(list: &[T]) -> T {
    let mut largest = list[0];

    for &item in list.iter() {
        if item > largest {
            largest = item;
        }
    }
I'm sure experienced Rust devs look at that and say it's fine, but that's definitely a hurdle for new developers.
Re:Comparing Parallel Rust and C++ by slavik81 on Friday November 08, 2019 @09:45PM (#21489220)
You need to specify the properties of T that you use. So, that first line should be:

  fn largest<T: PartialOrd + Copy>(list: &[T]) -> T {
https://tomtongue.com/docs/rust-wk-20.html#trait-bounds
Re:Comparing Parallel Rust and C++ by pcwalton on Friday November 08, 2019 @02:22PM (#21485745)
What would you want to see instead? That's pretty much the same syntax as generics in Java.
Re:Comparing Parallel Rust and C++ by blub on Thursday November 07, 2019 @10:46AM (#21474185)
Then the only reasonable conclusion is that the Rust community has different tastes compared to the mainstream programming community. To put it euphemistically.

The Swift team probably also agonized over syntax decisions and they came up with something very different which has won over many people and attracted little criticism.

Re:Comparing Parallel Rust and C++ by pcwalton on Thursday November 07, 2019 @11:01AM (#21474335)
The only concrete thing I've seen brought up so far is that some people don't like the keyword "fn". Swift chose "func". Is there really a huge difference? (I prefer "fn", by the way.)

Swift also doesn't have pervasive use of lifetimes like Rust does. Lifetimes, by their nature, always add some level of "noise".

Re:Comparing Parallel Rust and C++ by blub on Thursday November 07, 2019 @11:50AM (#21474826)
When people do make an effort and outline pain points, those are waved away by Rust programmers or deflected by claiming that they like said syntax choice.

At the end of the day though, these tiny thing like fn, or the lifetime annotations and the many others add up to an unpleasant experience and less readable code.

Re:Comparing Parallel Rust and C++ by pcwalton on Thursday November 07, 2019 @12:41PM (#21475305)
If Rust were an unpleasant experience, it wouldn't have users. I'm sorry that you disagree with the syntax decisions. We can't please everybody.
Re:Comparing Parallel Rust and C++ by blub on Thursday November 07, 2019 @02:33PM (#21476498)
I'm not an extremist, the language clearly has certain advantages. At the same time I do believe it could have a lot more users if it were a more pleasant experience.

If it becomes a mainstream language (like Java, C++, etc), I'd be happy to concede I was wrong. It could be that memory safety will trump ergonomics and it wouldn't be the first time that somewhat painful to use tools become very popular - see Linux, git, etc.

Re:Comparing Parallel Rust and C++ by rat9988 on Thursday November 07, 2019 @12:18PM (#21475074)
Lifetime annotations are an other ugly unreadable quirk. I'm happy to know I'm not the only one.
Re:Comparing Parallel Rust and C++ by pcwalton on Thursday November 07, 2019 @12:38PM (#21475264)
Those aren't syntax though. Without lifetimes you don't have memory safety without GC. There are plenty of languages that don't have memory safety, and plenty of languages with GC, but they don't broadly share Rust's goals.
Re:Comparing Parallel Rust and C++ by rat9988 on Friday November 08, 2019 @07:08AM (#21481529)
The problem is not lifetime but its annotation.
Re:Comparing Parallel Rust and C++ by rezeroed on Thursday November 07, 2019 @02:25PM (#21476430)
fn is great. I'm not at all mathematical as suggested by others. When I go back to Go I find myself wondering why I have to type the extra two characters.
Re:Comparing Parallel Rust and C++ by FpUser on Thursday November 07, 2019 @11:07AM (#21474422)
I would very much prefer function over fn , just for plain readability . Of course it is subjective but whatever.
Re:Comparing Parallel Rust and C++ by gpderetta on Thursday November 07, 2019 @04:39PM (#21477589)
Strupstup law is relevant here:

"For new features, people insist on LOUD explicit syntax. For established features, people want terse notation."

fn is fine.

Re:Comparing Parallel Rust and C++ by rezeroed on Thursday November 07, 2019 @02:28PM (#21476455)
fn usually appears at the start of a line following an empty line - how is it not readable? I honestly think even fn serves little purpose, other than compiler parsing. New paragraph == new function.
Re:Comparing Parallel Rust and C++ by FpUser on Thursday November 07, 2019 @06:30PM (#21478507)
Whatever tickles your fancy. To each their own