8 ms·
I think its more like, "I have no chance of understanding your code, BECAUSE IT'S IN R." The vast majority of R users and I bet 95% of ecologists, can't read an
by rjurney 12y ago
I think its more like, "I have no chance of understanding your code, BECAUSE IT'S IN R." The vast majority of R users and I bet 95% of ecologists, can't read and understand R modules. Its the PHP of Data Science.
The point, then is to supply code with simple instructions so that anyone can run it. Secondary goal: write it in a language a human can actually read.
If you're doing science and you want people to understand your code, you use Python, not R.
- hayd 12y agoAlso, many R packages end up being written in cpp.
- _kst_ 12y agoDo you mean C++? (It's a pet peeve of mine. The language is called "C++". "cpp" is commonly used as the suffix for C++ source file names, but the name "cpp" also refers to the C preprocessor.)
- capnrefsmmat 12y agoThe common R package for integrating C++ is called "Rcpp", so calling it "cpp" isn't that strange in context.
- rjurney 12y agoMany Python packages are written in C. So long as there's a clean interface, I don't see it as a problem.
- hayd 12y agoThere's no problem here, the issue is that the journal reviewers were complaining the code wasn't written in R, which seems strange when non-vectorizable algorithms essentially force code to be written in another language (the same is true for python/numpy - sometimes you need to drop to cython).
- hackerews 12y agoOption 2: Make an API with a simple and well-documented interface. Forget about the language BS.
- bachmeier 12y ago> If you're doing science and you want people to understand your code, you use Python, not R. Wouldn't that depend on which language "people" know? > Its the PHP of Data Science. Some might disagree with that statement. Some might even argue that languages where for loops are idiomatic and strongly promoted by the BDFL are the PHP of Data Science.
- rjurney 12y agoIf so, you're the first "people" I've ever heard this argument from :)
- deanjones 12y agoI don't disagree, but PHP is not the canonical reference for code which cannot be understood, that would be Perl. PHP is the canonical reference for code which can be understood but not interpreted, because you don't know the values of various obscure global flags.
- lsiebert 12y agoSee Perl seems easy to read to me, and functions work like I expect, whereas PHP has a bunch of functions where variable order is not consistent. R isn't horrible, and if you are in the repl, you can print any function's code you can access, which is awesome.
- x0x0 12y agoPython is an ugly language for scientific work; any of R, matlab, or julia are far preferable for not massively obscuring the intent of your code with the programmatic hoops you have to jump through. People who are programmers I think tend to wildly underestimate the effort needed to learn and read python. Further, the vast majority of R modules are at least partially implemented in R and tend to be very readable.
- hogu 12y agowhat hoops are you referring to? My phd work was all matlab, and I vastly prefer python for readability and practicality
- x0x0 12y agoAny linear algebra looks ugly -- python: X.dot(Y) matlab: X*Y R: X %*% Y It makes less difference when it's only 2 matrices, but when it's 3+ it's far more readable. pandas has a lot of functionality, but the interface is far inferior to R's data frame, where you have df[row predicate, column predicate] particularly the highly useable intermingling of column access by index or name. reshape2 and plyr are, imo, far more elegant and less wordy apis. The api to sklearn, while definitely more consistent than R's apis, has a lot more programmer nonsense interjected: imports of random packages, the difference between pandas and numpy that still peeks through the second you step outside of statsmodels, etc. numpy has a serialization format, while pandas uses pickle or hd5. R just uses save/load, and unlike pickle in my experience, it reliably works. matplotlib is an ugly api, particularly compared to ggplot.
- hogu 12y agofew things that do not completely address your points, but may help - python 3 (.5?) is adding the @ operator for matrix multiply. Of course this only helps you if your company uses python3 - There are 2 packages (seaborn, ggplot(clone)) which sit on top of matplotlib and provide a much nicer interface for statistical plots
- 12y ago
- hadley 12y agoIf 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.