5 ms·
>The safety Rust offers makes you a better programmer, because in C++ your focus is partially (mostly?) tied up to provide guarantees Rust provides for free. U
by logicchains 8y ago
>The safety Rust offers makes you a better programmer, because in C++ your focus is partially (mostly?) tied up to provide guarantees Rust provides for free.
Unfortunately there are still some very nice safety benefits that C++ provides but Rust doesn't: those relying on integer template parameters. C++ for instance allows checking at compile time that matrices with sizes known at compile time can be multiplied together, while in Rust this would be a runtime error. Even if Rust got integer template parameters, it's still a long way away from supporting variadic template parameters, which allow creating tensors of arbitrary dimension and for checking operations on them at compile time.
This is not just a safety issue but also a performance issue, as libraries like xtensor(https://github.com/QuantStack/xtensor https://github.com/QuantStack/xtensor) allow stack-allocating such arrays, but (correct me if I'm wrong, this may be outdate) there's no way to implement a stack-allocated tensor of arbitrary dimensionality in Rust. Expression templates, an important technique for improving linear algebra performance by performing optimsation of computation graphs at compile time (kind of like Haskell rewrite rules, but implemented entirely as libraries) are also harder to use in Rust.
- steveklabnik 8y agoWe've accepted an RFC for this, and hopefully will have an implementation on nightly by the end of the year, with stabilization sometime next year, incidentally.
- pjmlp 8y agoSo can we hope to see something like Eigen in Rust?
- steveklabnik 8y agoHopefully! The RFC I'm referring to[1] is the first step; this isn't my area of specialty, so I can't say if it alone is enough to replicate it. But if not, it's the first step towards it. The end goal is first-class support to allow people to build excellent libraries like Eigen. 1: https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md https://github.com/rust-lang/rfcs/blob/master/text/2000-cons...
- logicchains 8y agohttps://www.reddit.com/r/rust/comments/6nexpo/variadic_generics_and_higherkinded_types_when_to/ https://www.reddit.com/r/rust/comments/6nexpo/variadic_gener... suggests that we however won't be seeing variadic generics for quite some time, so it still won't be possible to build a library like xtensor supporting tensors of arbitrarily many dimensions.
- steveklabnik 8y agoAll of that stuff mentioned that would happen before it has almost happened. There isn’t an accepted RFC yet, so it will be some time still, but it is a desired feature.