Sometimes, R code just isn't fast enough. Sometimes, you've used profiling to figure out where your bottlenecks are, and you've done everything you can think of within R, but your code still isn't fast enough. In those cases, a useful alternative can be to delegate some parts of the implementation to more efficient languages such as Fortran and C++. This is an advanced technique that can often prove to be quite useful if know how to program in such languages.
Delegating code to other languages can address bottlenecks such as the following:
- Loops that can't be easily vectorized due to iteration dependencies
- Processes that involve calling functions millions of times
- Inefficient but necessary data structures that are slow in R
Delegating code to other languages can provide great performance benefits, but...