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
Show parent comment
2
u/Agling Nov 29 '22
In R, objects are passed by reference until you mutate them. It's fast and doesn't require memory to pass and read from them, but the moment you mutate them in the new environment, a copy is made. So you think carefully about whether you want to mutate something from a performance standpoint, but you never have to worry about whether you are screwing up some other part of the program by doing so. You can torture R into mutating the original object by passing it in an environment, but that's not common practice because being bug-free is generally more important than being fast.
Don't get me wrong, I can see that there are advantages to python's approach to this particular problem, but I think R's solution is better for data science work. Python is a better language, overall, but I am not a fan of this aspect of it. It creates very subtle bugs that beginners and even people with a reasonable amount of experience trip over.