[R] [R-pkgs] Rcpp11 3.1.0 is on CRAN.

Romain Francois romain at r-enthusiasts.com
Fri Apr 11 14:48:43 CEST 2014


R version 3.1.0 was released yesterday, and as always is welcome with great pleasure. One
of the features that is of particular interest to me is the support for C++11. 
I would encourage you to read 
[Writing R Extensions](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-C_002b_002b11-code)
to familiarize yourself with 
what this supports means and how to take advantage of it. C++11 is a major 
upgrade of the C++ standard, making C++ more expressive, more efficient, more
fun to use and teach. It almost feels like a new language if you embrace it fully. 
The standards committee has done a great job of maintaining compatibility, which means
that code written with older standard will still compile and work. 
However, with C++11 code you write today and tomorrow will not be the same as code 
you used to write with C++98. 

To get the best of what C++11 has to offer, I'm releasing Rcpp11 today. Rcpp11
is a complete redesign of Rcpp, focused on C++11. Rcpp11 is a header only 
C++ library, distributed as an R package on CRAN, that facilitates embedding 
C++ code in R packages. 

I'll try to keep this announcement short. More details will follow on dedicated 
channels. I will just highlight a few aspects of Rcpp11 that are high level 
enough for such an annoucement. 

Header Only

Rcpp11 is header only -- it consists only of a set of `.h` files. Rcpp11 has no
`.cpp` files, and no R functions. This eliminates many problems inherent to 
binary compatibility that Rcpp has been fighting with for years. 

The recommended way to use Rcpp11 is to have these lines in the `DESCRIPTION` file 
of your package: 

LinkingTo: Rcpp11
SystemRequirements: C++11

Modernized code base

Many features of the original Rcpp code base are the consequence of my 
learning C++ and the internal API of R. After a few years of experience, I can 
now admit that mistakes were made while designing it. Unfortunately for reasons
outside of my control, it is not possible to fix these mistakes under the umbrella
of the Rcpp package. 

Things are radically different for Rcpp11, which I will maintain. Over the past 
few months, I have considered many features of the code base and either decided
to abandon them or upgrade them to the level of expectation we should have for a 
modern R/C++ interface. 


Most of what is usually called the API has been retained. I do not guarantee
low level compatibililty, but there is conceptual compatibility. For example, 
Rcpp11 contains all the classes we would expect: `NumericVector`, `List`, ...

I'm not going into details about what the individual differences are. Instead I 
will start documenting how to use the API provided by Rcpp11. 


Attributes is probably the best feature that has ever been contributed to Rcpp. It 
gives a mechanism for decorating C++ functions, parsing these decorations and generating
scaffolding code around them.  

This feature has not been retained in Rcpp11, but instead has been moved into a 
new package called [attributes](https://github.com/Rcpp11/attributes), 
which is being developed and will be released later. 

It is worth mentioning that code generated by Rcpp's `compileAttributes` function
should be compilable against Rcpp11. When attributes becomes available it will 
provide a more flexible approach, and provide facilities for package authors to
implement and use their own attributes.


Rcpp modules was not retained as part of Rcpp11. This was a hard decision, because
I invested a lot of time developing the original code behind Rcpp modules. However
modules have significant problems which make them hard to maintain. Modules are 
also very demanding on the compiler. 

However, I still believe that the promise of Rcpp modules -- exposing C++ classes 
at the R level -- is very worthwhile. My plan is to redesign it using a different 
approach, more oriented towards code generation, à la attributes. 

Time and Date classes

I decided to abandon the classes responsible to handling dates and times. Better 
classes might be introduced when I'm comfortable with the design. Design 
documents and pull requests are welcome. 

Further discussion

Please consider subscribing to the R and C++ mailing list that was created a few 
days ago: https://groups.google.com/forum/#!forum/r-and-cpp

The scope of the mailing list is broader, the intention is to discuss all things 
R and C++. Questions about Rcpp11, Rcpp or anything related to using C++ and R
are welcome. As of today, 37 participants are registered. Please consider 
replying to this annoucement email through the mailing list. 

Rcpp11 is developed through the Rcpp11 organisation on github. Feel free
to report issues and submit pull requests. https://github.com/Rcpp11/Rcpp11


The pattern that has been decided for versions of Rcpp11 is to use the same 
number as the mininum version of R required. Therefore this initial version
is Rcpp11 3.1.0 and interim releases might be called,, etc ...


There is no documentation yet. I personally find the heterogeneous sources
of documentation for Rcpp to be confusing. I have three goals in terms of 
documentation for Rcpp11:

 - An article is being written. This will be a casual introduction to 
   interesting features of C++11 and Rcpp11.
 - API documentation. My goal is to have a website that will make easy to 
   browse internal documentation (what to do with a NumericVector, ...) similar
   to cplusplus.com or something. 
 - I have started working on a R and C++ book. As I personally consider that 
   C++ = C++11 from now on, the book will mainly cover uses cases of Rcpp11. 

I hope to that between now and useR this year, I will make progress on the 2 first 
items of the previous list. 


Rcpp11 is licensed under the MIT license.


This is the first release, it has required a lot of time and effort from me and
Kevin Ushey who has stepped in as a regular contributor to the package. 

This sets us with a new foundation for interfacing R and C++ for years to come. 
Many features of C++11 such as regular expressions and threads have not been 
leveraged yet with this initial release. 

C++ is more alive than ever, a new minor update of the standard is likely to 
be released this year and supported at day 0 by popular compilers. At this point
I do not anticipate to start working on a Rcpp14 package. 

In a few years (the ETA is currently 2017), a new major version of the C++ standard
will be released. It is too soon to say if it will be worthwhile to have a Rcpp17, 
but from a casual reading of the expected features, I'd say it is likely. 

I sincerely hope you will enjoy working with Rcpp11.


R-packages mailing list
R-packages at r-project.org

More information about the R-help mailing list