Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unpopular opinion: I find rust code unreadable. And I consider myself a polyglot. I am sure all those symbols have a special meaning but it's like perl to me. Just throw some random special characters and they all mean something.


Perl did nothing wrong, but I echo the sentiment you have about Rust.

Last year I ported a mid size internal project to it as part of a resolution to learn a new language and the experience left me feeling like it was just me who "didnt get it". Building things took a lot longer, not just in the amount of code, but also the compile time. Ultimately compile time was the dealbreaker. On more than one ocassion I'd have to go back to the git history to remember what it was I had planned to do next.


Rust pro tip: don't compile til you're really done. Use something like cargo check or rust-analyzer to quickly spot errors without wasting time on the rest of compilation.


Thanks for the tip


You are not the only one. I find rust code unreadable too even though I can understand it. I wish the type signatures and function definitions were on separate lines a la Haskell. That would have drastically improved the legibility.


You can do that in Rust by using a "where" clause. Put in a letter for each type, then define them on different lines.


Anything with trait bounds beyond `fn foo<T: Trait>(t: T)` should put them in the `where` clause (and in this case, it arguably should be `fn foo(t: impl Trait)`).


It's unreadable until you learn the language. It is not something you can just look at and start writing/reading.

Also there aren't that many special symbols, it's not scala after all.

Spend two weeks with it and it makes sense why things are the way they are for the most part.


My only gripe of Rust's syntax is the lifetime annotation, but I can't suggest any better alternative, either.

> And I consider myself a polyglot.

Then you should realize that Rust borrows some of its syntax from other languages:

- Function's parameter and return types are borrowed from Python's type annotations.

- Turbofish syntax is from C++.

- Closure syntax follows Ruby's.


I completely agree. I think the syntax looks awful, for one. This has put me off learning it completely.


I had that same issue but got over it once I started diving into rust. What really helped me are the compiler error messages. Without that i would have given up learning it


I find it readable, but I do sympathize. I would have like to have seen it look more like an ML language such as OCaml or F#.


Nothing a couple of days can't fix. Unless you have single-unpaired-quote-phobia.


I find Rust easier to read in a real IDE with semantic highlighting (although the IntellIJ plugin constantly breaks this) and inlay type hints so that everything doesn't end up blurring together.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: