5 ms·
> 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.
by pcwalton 7y ago
> 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.
- blub 7y agoThen 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.
- pcwalton 7y agoThe 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".
- blub 7y agoWhen 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.
- rat9988 7y agoLifetime annotations are an other ugly unreadable quirk. I'm happy to know I'm not the only one.
- pcwalton 7y agoIf 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.
- blub 7y agoI'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.
- FpUser 7y agoI would very much prefer function over fn , just for plain readability . Of course it is subjective but whatever.
- rezeroed 7y agofn 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.
- FpUser 7y agoWhatever tickles your fancy. To each their own
- gpderetta 7y agoStrupstup law is relevant here: "For new features, people insist on LOUD explicit syntax. For established features, people want terse notation." fn is fine.
- jandrese 7y agoI'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.
- pcwalton 7y agoI 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?
- jandrese 7y agoI'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.
- pcwalton 7y agoWhat would you want to see instead? That's pretty much the same syntax as generics in Java.
- slavik81 7y agoYou 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 https://tomtongue.com/docs/rust-wk-20.html#trait-bounds
- rezeroed 7y agofn 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.