Hacker News new | ask | show | jobs
by k__ 1173 days ago
"the most difficult part was stopping myself from forcing aesthetical ideas of how to structure code from the other languages"

Coming from C and PHP to JavaScript gave me similar cognitive dissonance.

Syntactically these languages are very similar, but the semantics require to rethink quite much if what I learned.

1 comments

Yeah, I wish there was a good list of things to hint you aren't being rusty. When you are cloning everything or have arc on everything that is a pretty good hint, but I'm sure someone could put together a better list than I could.
Clippy can help you to write more idiomatic Rust, so if you aren't already, definitely check out the clippy lints for a working program you wrote:

  cargo clippy
Clippy won't tend to spot unnecessary Arcs and similar architectural mistakes, however it would notice if you act as though things aren't Copy when they are [e.g. you've probably never 100.clone() but if you did Clippy would point out that's just 100 and the same would apply to types where it's less obvious that they're Copy and you might have forgotten]
Yeah clippy is amazing, but I was thinking things everyone has to do sometimes in rust, but that if you find yourself having to resort to them often might be a hint that your overall paradigm might need a tweak to fit well. I didn't mean unnecessary arcs, but rather necessary ones. I find that if I donthings the way Ferris wants me to, that I dont have arc, rc, refcell, or clone very often, and nothing ends up needing to derive copy. When Ferris is happy my life is easier.