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

> My first language was C++ so I think that's probably biasing

It is. Anyone coming from anything else than C or C++ will struggle for a while. A lot of things make sense now for me in Rust after days / weeks of playing around with small apps. But the 2 types of String is still one of these thing which anytime I read about it makes (sort of) sense, but then ... Well, I know that using a string literal (with possibly a lifetime) instead of a string, or adding `to_string()` will probably solve my problem. Thankfully the borrow checker along rust analyzer are extremely smart and 2 things which are built to the (close) perfection - the dev experience for beginners would be a total nightmare if it was as messy as the typescript linter



A lot of people seem to get hung up on String vs. &str, but never seem to have trouble with Vec<T> vs. &[T], which is pretty much completely analogous except for the fact that the UTF-8 representation of strings makes it so you can't easily index to a given character.


Part of the problem is naming. They got it right with Path/PathBuf, but str/String is really confusing.


I came to Rust from Scala and I think it actually really helped. My first non-trivial Rust project was a straight port of a Scala library and it was actually pretty uncanny how straightforward the translation was. I'm sure the Rust code could have been optimized to avoid a few clones here and there but in general I've found that you can avoid a lot of the really tricky edges of Rust by just using clone/Arc/Box/etc. In non performance-critical code sections it's probably not even worth avoiding those things.




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

Search: