4 ms·
If you want people to understand your code, you need to treat it like writing: rewrite, rewrite, rewrite. The language itself is almost irrelevant: you can writ
by hadley 12y ago
If you want people to understand your code, you need to treat it like writing: rewrite, rewrite, rewrite. The language itself is almost irrelevant: you can write horrible code in Python and beautiful code in R.
- an_d_rew 12y agoActually, no. I have written several modules and packages in R, both native and C++, and it is impossible to write efficient R that is beautiful or even comprehensible.
- craigching 12y agoHopefully you know the parent was Hadley Wickham who has very much contributed to the readability and beauty of R. So much so that even Python data scientists are lamenting that their code is not quite as beautiful as the "hadley stack" [1] FWIW, I've done both Python and R and they both have their pluses and minuses, but beauty is in the eye of the beholder and I've seen some R packages that do, indeed, make R beautiful, case in point, the dplyr package from Hadley Wickham. I'd love to see the future of R be inspired by dplyr and ggplot. [1] -- http://technology.stitchfix.com/blog/2015/03/17/grammar-of-data-science/ http://technology.stitchfix.com/blog/2015/03/17/grammar-of-d...
- rjurney 12y agoTrue, but if you write decent or so-so Python code, it is readable to anyone who knows a C like language. So-so R code is still impenetrable. The language matters. One is optimized for ... honestly I have no idea what R is optimized for. I don't think R works that way. It just is. Python though, its optimized for readability.
- x0x0 12y agopython is optimized for readability to C programmers R is optimized for statisticians
- hadley 12y agoBadly written R is impenetrable. So is badly written R. I suspect your standards for so-so R code are vastly different to mine. R and Python really are very similar as languages. R is more functional, but that shouldn't impede your ability to understand code (once you master some of the basic idioms of FP)
- rjurney 12y agoI can't actually comment on what is good/bad R code, because I've never seen any R code beyond a few lines that I could follow.