25.8 Learning more

This chapter has only touched on a small part of Rcpp, giving you the basic tools to rewrite poorly performing R code in C++. As noted, Rcpp has many other capabilities that make it easy to interface R to existing C++ code, including:

  • Additional features of attributes including specifying default arguments, linking in external C++ dependencies, and exporting C++ interfaces from packages. These features and more are covered in the Rcpp attributes vignette, vignette("Rcpp-attributes").

  • Automatically creating wrappers between C++ data structures and R data structures, including mapping C++ classes to reference classes. A good introduction to this topic is the Rcpp modules vignette, vignette("Rcpp-modules").

  • The Rcpp quick reference guide, vignette("Rcpp-quickref"), contains a useful summary of Rcpp classes and common programming idioms.

I strongly recommend keeping an eye on the Rcpp homepage and signing up for the Rcpp mailing list.

Other resources I’ve found helpful in learning C++ are:

  • Effective C++ (Meyers 2005) and Effective STL (Meyers 2001).

  • C++ Annotations, aimed at knowledgeable users of C (or any other language using a C-like grammar, like Perl or Java) who would like to know more about, or make the transition to, C++.

  • Algorithm Libraries, which provides a more technical, but still concise, description of important STL concepts. (Follow the links under notes.)

Writing performance code may also require you to rethink your basic approach: a solid understanding of basic data structures and algorithms is very helpful here. That’s beyond the scope of this book, but I’d suggest the Algorithm Design Manual (Skiena 1998), MIT’s Introduction to Algorithms, Algorithms by Robert Sedgewick and Kevin Wayne which has a free online textbook and a matching Coursera course.

References

Meyers, Scott. 2001. Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library. Pearson Education. http://amzn.com/0201749629.

Meyers, Scott. 2005. Effective C++: 55 Specific Ways to Improve Your Programs and Designs. Pearson Education. http://amzn.com/0321334876.

Skiena, Steven S. 1998. The Algorithm Design Manual. Springer. http://amzn.com/0387948600.