[R-pkg-devel] R, Rust and CRAN

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Sat Nov 12 19:59:05 CET 2022


On 12 November 2022 at 19:27, Jeroen Ooms wrote:
| On Sat, Nov 12, 2022 at 12:49 AM Simon Urbanek
| <simon.urbanek using r-project.org> wrote:
| >
| > this does not directly address your question, but I think it would make a lot of sense to standardize the process, given how many issues there were with packages using Rust (mainly not detecting compilers correctly, not supplying source code, unsolicited writing into user's directories, not checking binaries etc.). Doing this right is not entirely trivial which is presumably where the "friction" comes from.
| 
| All we need is the rustc/cargo toolchain to be installed on the CRAN
| win/mac builders (it already is on Fedora/Debian). As mentioned above
| (and before in e.g. https://jeroen.github.io/erum2018), rust uses the
| native C FFI, does not need any runtime library, and can be called
| directly from an R package using the C interface.  There is really no
| need for frameworks or engines (like Rcpp/rJava/V8), this is precisely
| what makes Rust so nice as an embedded language, and why it is being
| adopted in many C projects such the Linux kernel, that would never
| want to deal with Java/C++/JS.

Seconded. CRAN works best when tools are uniformly provided. It would be good
to have that for Rust too.

(Small nit about C++ here. Its compatibility with C and use of FFI via C is a
major reason for its success. As you know there is no run-time so equating
with Java or VS is a little off, at least on my ledger.)
 
| > I'm not a Rust user myself, but just based on the other languages that have interfaces from R I would think that Rust users could coalesce and write a package that does the heavy lifting and can be used by packages that contain Rust code as a foundation - that's what most other language interfaces do. (It's quite possible that some of the projects you listed would be a good start). I would not recommend putting that burden onto each package author as it screams maintenance nightmare.
| 
| I understand the sentiment but Rust is very different from e.g. Java.
| There really isn't much "heavy lifting" to do, because there are no
| complex type conversions or runtime library involved. If the same
| structs are used in C and Rust, the C functions can directly call Rust
| functions and vice versa. Therefore it is possible for libraries to
| incrementally port pieces of C code to Rust without breaking the ABI.
| Just have a look at the hello world examples such as:
| https://github.com/r-rust/hellorust or for a real world example:
| https://cran.r-project.org/package=gifski

Again, ditto for C++ but Rust is another very compelling candidate that would
be good to support (and to e.g. access projects like polars more easily).

CRAN is often seen as having somewhat difficult-to-overcome resistance for
outside help (with Rtools4 a very notable and successful exception).

Maybe enabling Rust support could be a pilot-project for another approach?

Dirk

-- 
dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-package-devel mailing list