Other than the lineprof tool and the Rcpp comment, most of this applies directly to MATLAB code as well. I had the unfortunate pleasure of dealing with roughly 15k lines worth of MATLAB simulator code for a class I took in undergrad (no choice as to the language we used). Only tweak: Instead of lapply -> mclapply, switch for -> parfor. MATLAB complains about dependency stuff (which was nice to not have to reason about separately) but it provides decent error messages about what looks dependent.
Other than the lineprof tool and the Rcpp comment, most of this applies directly to MATLAB code as well. I had the unfortunate pleasure of dealing with roughly 15k lines worth of MATLAB simulator code for a class I took in undergrad (no choice as to the language we used). Only tweak: Instead of lapply -> mclapply, switch for -> parfor. MATLAB complains about dependency stuff (which was nice to not have to reason about separately) but it provides decent error messages about what looks dependent.