5 ms·
What I would like to see is something where people could submit a small working program in one language and a Rust expert would make a program that does the sam
by Lerc 8y ago
What I would like to see is something where people could submit a small working program in one language and a Rust expert would make a program that does the same thing in idiomatic Rust. This doesn't need to be anything too complex. A wiki would be fine, the work would be in having volunteers to make the demos.
If you don't know the idioms you end up doing a sort of transliteration of the source language where the concepts may work against the nature of Rust. A developer can spend a long time barking up the wrong tree with few indicators as to which is the right tree.
As an example of what I mean. Here is a program that I wrote in JavaScript specifically because I could not find a way to write it in Rust that felt like I was doing it the right way.
https://codepen.io/Lerc/pen/yQxmob?editors=0010 https://codepen.io/Lerc/pen/yQxmob?editors=0010
I could come up with Rust versions that were basically emulating pointers with array indexes(and a mess when something is deleted), or map versions that incurred lots of run-time lookup. The crux of the problem, I think is either how to do a mutable graph of mutable nodes, or how to do map on a immutable graph of immutable nodes to a new immutable graph of immutable nodes in the next state along.
I'm sure others have this issue of "I know how to do it in X, doing it that way in Rust is a mess, what's the right way?"
- steveklabnik 8y agoArray indices with generational indices are popular, by the way. I think this idea is pretty good!
- epage 8y agoI agree about the need for an Idioms Cookbook or something to show different practices. We have one for how libraries can help you solve problems but not code patterns..
- em-bee 8y agotake a look at http://rosettacode.org/wiki/Category:Rust http://rosettacode.org/wiki/Category:Rust more than 400 code examples have a solution in Rust.
- steveklabnik 8y agoThere’s no real guarantee of quality or idiom there, though.
- em-bee 8y agobut that's something the rust community could take care of. should be much less work than creating yet another repository. i think there was at least one language that made rosettacode their official repository for code examples. so all their solutions were vetted by experienced developers. i believe the rosettacode maintainers would allow adding a note to each example that has been checked. (simply add it to the description of the solution, so that people know which examples are recommended)
- em-bee 8y agoyou could also create a list of links to approved rosettacode examples