5 ms·
rust has an awful readability issue. its syntax is too irregular and permissive. (too much ruby?) people tend to disagree, but syntax is very important. that i
by blondin 7y ago
rust has an awful readability issue.
its syntax is too irregular and permissive. (too much ruby?) people tend to disagree, but syntax is very important. that is, in fact, why python has won the scientific community. we don't wanna be spending brain cycles deciphering syntax.
as a side note, we blamed java for being verbose for years. in retrospective, java was right. i have never seen a piece of java that i couldn't understand. i may not know why the code is doing what it's doing, but i always know what the code is doing.
java has stellar readability!
with rust, only time will tell. my gut feeling is that the readability will not help the language when programs get old.
- saghm 7y agoCan you elaborate on what exactly you don't like about Rust's syntax? I'm always surprised when I hear this, because a lot of the things that get pointed out tend to have good reasons for the way they are.
- steveklabnik 7y agoRust takes inspiration from several disparate sources. There’s something for everyone to find a bit alien. (That’s my working theory at least)
- Koshkin 7y agoPL/I has done it, famously, and just as famously the language has turned out horribly misdesigned and complex, and it also has missed out on most new ideas. (Still in use though.)
- edflsafoiewq 7y agoBut it doesn't matter. If the language is unreadable, even if every syntactic decision followed by necessity alone from a set of first principles, it wouldn't prove the language was readable. It would only prove the selected principles necessitate an unreadable language. Compare [x for x, y in v] to v.iter().map(|&(x,y)| x).collect::<Vec<_>>(). There is a good reason for every bit of ugliness, but that does not change the fact that it is ugly.
- saghm 7y agoI agree that the snippet you gave is ugly, but I also think that it's not really the most straightforward way to right it. Any time the type that you're collecting into isn't inferred, you're free to define a binding and just type annotate it. Also, the lambda you gave is not defined in the straightforward way I think most people would define it. Putting those together, you get something like this: ``` let vec: Vec<_> = v.iter().map(|pair| pair.0).collect(); ``` I don't think that's really _that_ ugly. Yes, the pithy Python example you gave is simpler, but by the same token, the assembly you would write to achieve this makes the Rust look really simple. If you're going to try to write efficient code in a systems language like Rust, you're going to need to express things more precisely than you would in a scripting language like Python.
- sgift 7y agoReadability is very often nothing else but habit - code which looks like code you've seen often enough looks well. Case in point: The first example is just gibberish to me and I needed the second one to decipher it. Also, I would write the second example different: let r: Vec<_> = v.iter().map(|(x,_)| x).collect(); In my opinion that's superior in readability to both of your examples, but probably also only because I'm used to it.
- deleted 7y ago[deleted]
- edflsafoiewq 7y agoYour r has a different type.
- oblio 7y agoThe lambda syntax, to me. Why go Ruby |it| instead of Groovy it -> ? The first one is ugly. Maybe for easier parsing? Then ' for lifetimes. Personally I like short keywords. Maybe "life"? Then there are the <> generics which some don't like. And most modern languages don't have references anymore plus & was always ugly and non intuitive as a symbol. Again, maybe a short keyword? "ref"?
- saghm 7y agoThese all seem like small personal preferences to me, which are entirely valid; I don't think it's possible for a language to have a syntax that pleases everyone. But the comment I was responding to described Rust as having an "awful readability problem", and I don't really see that being described here. In particular, the comment I was responding to described Java as having "stellar readability", so mentioning the generic syntax of Rust really surprises me. Is `Foo<? extends Bar>` really so much better than `Foo<T: Bar>`?
- danielscrubs 7y agoThe scientific community just want's the easiest language that gets the math/job done. They focus on the science and don't want to be bothered with the rest. They'd still use Matlab if that got the job done. Java is pretty much the opposite, very large focus on architecture with DI-magic and extremely verbose. The lasagna building has gone out of style and never reasoned well with scientists which is why they never used it in the first place.