News for hackers. Stuff that matters.
Re:Four years with Rust by Manishearth on Wednesday December 21, 2016 @02:44PM (#13232026)
> Rc is common in the Rust ecosystem

I'm really surprised you think that's the case. Most rust codebases I've worked with use Rc very sparingly, if at all. If a codebase does use Rc there's usually one central thing that is Rc'd, with everything else using regular memory management.

I have noticed that beginners coming from GCd languages often tend to structure their code in such a way that paints them into a corner where they must use Rc. This might be what hit you. I'm not really sure how to teach idiomatic Rust though.

Re:Four years with Rust by mr_luc on Thursday December 22, 2016 @09:58AM (#13237598)
> there's usually one central thing that is Rc'd,

Right.

In my case, I was using the nphysics library, which for unsurprising reasons uses Rc for entity handles.

Similarly, in my app's code, I used nphysics' proximity and contact handlers to watch for events that indicated a change in status. Those handlers needed to initialize/set values in a HashMap accessible (and periodically cleared by) the main sim loop -- 'one central thing' that is Rc'd.

It's not sprinkled everywhere in your codebase, and for obvious reasons most libraries don't need to use it. But in applications, a central loop + library-provided callbacks + some Rc'd state of doesn't seem too uncommon.

Re:Four years with Rust by echelon on Wednesday December 21, 2016 @03:28PM (#13232339)
> I'm not really sure how to teach idiomatic Rust though.

Learners should read and write lots of Rust. That's a great way to learn what is idiomatic. There will be early missteps, but thankfully the language makes it more comfortable when you do things the right way.

Re:Four years with Rust by Manishearth on Wednesday December 21, 2016 @03:55PM (#13232544)
Yeah, my advice in general is to pick a few rust codebases and start hacking on them.

But I would love to figure out how to teach this in a way that doesn't involve random codebases. Some folks learn by doing (I do!), but others fare better with tutorials.