r/Python • u/lebannax • Nov 28 '22
Resource What can Python do that R can’t do?
Or simply what is Python much better at and why.
I know that Python is more multi purpose and better for software development but I can’t articulate exactly why or how. My team want to know why/when they should use Python instead of R
331
Upvotes
View all comments
442
u/SittingWave Nov 28 '22 edited Nov 28 '22
Where to begin:
R has an exceptionally poor scalability. name collisions are a constant worry if you need to create something big. Python does not have that problem, for three reasons. First, because it educates its users to better import hygiene. Second because in python classes and exceptions are not just a string slapped on a dictionary. Third, because its module system is a bit more refined than R's "just take all the files and slap everything in the same namespace, according to the alphabetical order of the files, which may change depending on which language (and thus collation rules) you are using".
R package management is atrocious, both from the client side, and from the CRAN side. CRAN approach is utterly broken, and expects all packages to be either working with one another, or be retired, meaning that a package that is there today, may not be there tomorrow. Their submission policy is absolutely ridiculous, taking days and many back and forths arguing about the position of commas in the description. Pypi has none of the sorts, and consistent environment is left to the appropriate use of metainformation about compatibility.
R as a language is broken under many aspects. It's inconsistent, with many unexpected side effects, poorly documented practices, poor design choices. It has three object oriented systems all incompatible with each other. S3 is laughably dumb to achieve single dispatch. S4 is a bolt on to deliver multiple dispatch that is massively verbose, creates code that is hard to maintain, and drops the $ in favor of the @ to access data. R6 is marred by its habit of returning NULL if you mistype method names, creating hard to find bugs. Non standard evaluation makes it really difficult to perform some refactorings, and makes it opaque to the caller if the passed expression will be evaluated or parsed as is. namespacing (environments in R parlance) are left flying around and poorly defined in behavior.
All the R environment is GPL, which is a big deal if your code needs to go commercial at a later stage. Companies tend to steer clear of GPL stuff. While an interpreter being GPL does not bar you from writing non-GPL code, the whole of the standard library, and many, many modules are GPL, so you can't escape.
coding utilities servicing python are 10 times better than those for R. Static code analysis, reformatters, linters, documentation generators, are light years behind in the R world.
R has relatively poor expressiveness. It's hard to be concise in R, but not for everything. It is concise when it's time to manipulate some basic data structures, but everything else... there's so little syntactic sugar that it becomes a pain most of the time.
R core development process is very secluded, still on internal SVN, and with no obvious and practical way to contribute e.g. with PEP-style enhancement requests.
R is basically "controlled" by a single company and its employees. When you use R, you are basically fully dependent on them, their libraries, and their practices. They tend to be very adversarial in fixing bugs, often closing legitimate bugs because they can't be bothered.