Example of Rust code

bearophile bearophileHUGS at lycos.com
Fri Aug 10 17:39:43 PDT 2012


Walter Bright:

Thank you for the answer.

> 3. If you write Rust code in D, it will not work as well as 
> writing Rust in Rust.
>
> If you want D code to perform, you gotta write it in D. Not in 
> Rust, C, or Java.

I agree. Every language has its strengths and its specific 
qualities, so you can't ask for a perfect translation from code 
in language X to language Y. On the other hand when X and Y 
languages are meant to be used for similar computing tasks, it's 
good to have some ways to translate the purposes of X code well 
enough to Y.

Regarding the problem David Piepgrass has explained what was the 
point of that Rust code, ans why your code was missing the point.

The main point of my little comparison was to show the usefulness 
of some Rust features that were discussed for D too, like pattern 
matching, tagged recursive structures (in Phobos there is 
std.variant.Algebraic, but it's currently not usable to write 
that code), and the original nice way of allocating a struct on 
the stack and return a reference to it, to build that expression 
tree.

I suggest to welcome future comparisons between D with Rust in 
this D newsgroup, because full ignorance of Rust will _not_ help 
D growth.

Bye,
bearophile


More information about the Digitalmars-d mailing list