Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an R compiler to C/C++ exist?

I'm wondering about the best way to deploy R. Matlab has the "matlab compiler" (MCR). There has been discussion about something similar in the past for R that would compile R into C or C++. Does anyone have any experience with the R to C Compiler (RCC) that was developed by John Garvin at Rice?

I've looked into it, and it seems to be the only project that worked on compiling R code into executable code. And as far as I can tell, it isn't still being used.

[Edit 1:]: To be clear, I know that there are C and C++ (and Java, Python, etc.) interfaces to R (rJava, rcpp, Rpy, etc.). I'm wondering about specific ways to compile and deploy R code without installing R in advance.

[Edit 2:]: John Mellor-Crummey tells me that they're still working on RCC and hope to make it available in 4 months or so (at the earliest). I'll update this further if I find anything else out.

like image 296
Shane Avatar asked Sep 20 '09 22:09

Shane


People also ask

Does R have a compiler?

R doesn't compile.

Is C and CPP compiler same?

Even though most C++ compilers do not have different linkage for C and C++ data objects, you should declare C data objects to have C linkage in C++ code. With the exception of the pointer-to-function type, types do not have C or C++ linkage.

Are compilers written in C?

The operating system, the C compiler, and essentially all UNIX applications programs (including all of the software used to prepare this book) are written in C.

Do you need a compiler to run C?

C is a mid-level language and it needs a compiler to convert it into an executable code so that the program can be run on our machine.


2 Answers

A byte code compiler will be part of the R 2.13 release. By default it is not used in this release but it is available; I expect the 2.14 release will by default byte compile all base and recommended packages. The compiler::compile help page and the R Installation and Administration Manual give some more details.

like image 173
Luke Tierney Avatar answered Sep 25 '22 15:09

Luke Tierney


I had forgotten about the Rice project, it has been a while. I think the operational term here is stated at the top of the project page: Last Updated 3/8/06.

And we all know R changes a lot. So I have only the standard few pointers for you:

  • Luke Tierney, who not only knows a lot about R internals but equally about byte compilers, has been working on such a project. Nothing ready yet, and it would still work in conjunction with the standard R engine.
  • Stephen Milborrow has the Ra extension to R that works with his just-in-time compiler package jit
  • my Introduction to High-Performance Computing with R tutorials (most recent tutorial slides from UseR! 2009) covers the profiling, compiling extentions, parallel computing with R, ... part, including Rcpp and and a bit about RInside.

In short: there is no way have what you desire specific ways to compile and deploy R code without installing R in advance. Sorry.

Edit/Update (April 2011): Luke's new compiler package will be part of R 2.13.0 (to be released April 2011) but not 'activated' by default which is expected for R 2.14.0 expected for October 2011.

Edit/Update (December 2011): Prof Tierney just release a massive 100+ page paper on the byte-code compiler.

like image 42
Dirk Eddelbuettel Avatar answered Sep 23 '22 15:09

Dirk Eddelbuettel