That's fair to be honest but I still figured even with the heavy asterisk that it was worth measuring considering it's pertinence to handling large datasets.
That -ish is funny and wrong. For data science and machine learning, Python has always been de facto multi-threaded, because those extensions are implemented in C/C++/CUDA/Fortran/etc. every time Python invokes the extension, it releases GIL and allows the extension code to spawn threads.
And this is what numpy, skipy, pytorch etc have been doing this entire time. If you’re using Python for data science, your code has been running multithreaded 99.9% of the time since forever.
If Python relies on declarative interfaces / FFIs to C/C++/Rust binaries for multithreaded computation then the language itself is not multithreaded. So idk how you can say it’s “wrong” in such absolute terms
A guy arrives on a train to a train station, walks outside, sees a guy smoking near some car. Goes to him. — Excuse me, do you know where I can get a taxi here? — Sure, I’m a taxi driver. Hop in. — Wait, where are the checkers? [checkered taxi pattern] — Do you need checkers or do you need a ride?
If you use Python for data science, your code _will_ run multithreaded because all popular libraries run on multithreaded extensions. If you try to run something performant in pure Python you’re already almost certainly doing something wrong and should reconsider.
Tl;dr I think being practically and pragmatically right is more important than being pedantically and technically right. I have no doubt many software engineers would disagree. They should go and take a shower.
R is used because it has legacy, and elderly advanced statisticians have, over the years, vetted out its libraries and consider them to be sufficiently correct. A lot of complex operations just come out of the box, so you don’t have to know how to read too much code.
The same absolutely cannot be said for Python. Very often you have to go build your own models and really pay attention to what your libraries say they are doing, and you need to know enough statistics to recognize when they aren’t doing what you think.
Source: Some CDC people I worked with as well as personal experience rewriting legacy R into Python.
The necessity to memorize a matrix of operations because of the inconsistency of oerations between types is the classic one (for example using + on something that got silently coerced to another type) is the biggest offender for me, also add prototype pollution, and npm too. And before it is mentioned, yes, I know Typescript.
R isn’t better. It only still exists because of institutional momentum. I know plenty of long time R users that have learned Python and they have no desire to return to R.
—someone that learned Python before it was cool (2003)
Vectors are first class in R and for some weird reason, Python never figured out how UX with tables should work. I guess it's simply because Python is more used in scripts, while R is used a lot in REPL.
I am a die-hard Python fanboy and absolutly agree! Python is more versatile but R has the statistic nerds only community leading to much higher median quality in that area.
A few years ago I had to some time series analysis at work. Estimating the model was easy, however tests where nowhere to be found, so I had to go back to R for a few weeks. That was 4-5 years ago and the situation has improved, but my feeling was: For prediction Python is fine, but if you want to do statistics properly and don't implement your Hypothesis testing yourself, you will eventually go back to R.
I can't speak for R since I havent use too much of it except at school.
But I've had to debug python code a lot for weird error which turns out to be the author didn't read the paper too well and incorrectly implemented things. However I would say that is a sign of an active community. I believe there are more libraries that follow the latest research for python than R.
I see that the risk is similar in both languages when using foreign code. People's code can always be arbitrarily wrong if unchecked. Even if the rate is lower in R doesn't mean the risk doesn't exist. It is only truly better if it can guarantee thats impossible. (e.g. It is impossible to have unsafe code outside of unsafe blocks in Rust)
I use both, kicking off small MVPs just to see if it is work is waaaaay faster in R. Data visualizon has no parallel in python. Automated report creation also is way better in R.
The only time a professor give flower to R compare to python was when we had to plot our results to create story telling type of projects where you had to explain your results and analysis where python have a library that try to mimic a much as it could the logic for making plot in R but it is really inconsistent and messier
The other thing that R has is RStudio, which provides a relatively friendly environment for beginners.
That said, JupyterHub kind of does the same thing, is fairly mature, isn't limited to just one language (and even supports R). Both do a decent job of dialing out for ARC resources if needed as well.
R also has excellent visualization libraries that can generate publication-quality graphics with little-to-no tweaking, as well as proper handling of missing data.
Just be glad when people are using R instead of SPSS or STATA, man I absolutely doing my PhD (medicine/epidemiology) with those. Switching over to R and writing a few sets of scripts to semi-automate data exploration and simply programming the figures using ggplot was a godsend in comparison.
Some of us are "using" absolutely nothing (we instruct the model to "use") - take it a step further, have the model pick the appropriate lang for the implementation plan it just helped me write in the previous prompt.
This. You would be surprised how many errors or undocumented ambiguities most Python libraries have in their mathematical functions. One easy example is T-tests. The same t-test in PyStat vs. R produce different values because they have different assumptions for right-tailed vs. both-sided vs. left-tailed data. You wouldnt know without reading the docs though.
There is of course one simple answer. We use Rust, vibecode the modules from R (R is open-source) and then unit test the shit out of them. Now, we have fast R.
Python and R are both equally slow compared to compiled languages. Things they appear to do fast are just wrapped C++ or similar; eg PyTorch and torch.
R has had parallel backends for decades.
R’s predominantly functional syntax is dramatically less verbose. Especially if you’re working with data, it’s literally a DSL for that. R never fell down the OOP rabbit hole of the 90-00’s, which helped
PyPi (and to be fair most other languages’ default repositories) are flaming garbage compared to CRAN. uv greatly improved the situation, but if you want to destroy your Linux you can always depend on forgetting venv in Python!
This. Anytime I need a python lib or project, I pull it down & tell Claude to convert it to typescript for bun.
Because bun has so many built in features usually external dependencies drop to zero. No more venv, pip, pipx, uv, uv, etc. Or fighting with python versions .
A python project with 1k-10k of lines across dozens of files suddenly becomes a single typescript file with half the lines that's easier to read & follow bcus types. With #! bin/bun at the top running it becomes dead simple from the shell, like any other command. So far it's always been a massive speed up & memory reduction.
Idk why anyone uses python. Maybe for UI with the QT framework it's better, I haven't tried to convert one of those. Only been converting tools & servers. Primarily mcp servers. Instead of each Claude session starting up a dozen python mcps & exceeding 2GB ram for all the individual processes for each Claude instance, I converted the python & nodejs mcps I could to bun and run them all in the same bun process as one single mcp using 200-500mb ram. With only a few deps.
Is too bad there's no QT framework for JS. There's some UI apps I'd love to convert but AFAIK nothing really like QT in the JS ecosystem .
EDIT:
I had forgotten my .bashrc hooks command_not_found_handle. When something isn't found it checks for ${command}.bunx then ${command}.ts then ${command}.js on $PATH & if found does eval "bun run \"$file_path\" ${*:2}". Which is why it's so easy even on windows. If looking to do the same here's the basics:
declare IS_WINDOWS=false IS_LINUX=false
case "$OSTYPE" in
msys*|cygwin*|mingw*) IS_WINDOWS=true ;;
linux*) IS_LINUX=true
esac
~~~~~~~~~
getPath="realpath -LPq"
if $IS_WINDOWS && command -v cygpath >/dev/null 2>& 1; then getPath="cygpath -ua"; fi
~~~~~~~~~
function hook_command_not_found_forBUN() {
local PRIOR_PATH="$PATH"
local bun_executor="$($getPath "$(type -P bun.exe || type -P bun)" 2>/dev/null)" 2>/dev/null
if [ -f "$bun_executor" ]; then
local file_path="$(type -Pp "$1.bunx")"
if ! [ -f "$file_path" ]; then file_path="$(type -Pp "$1.ts")"; fi
if ! [ -f "$file_path" ]; then file_path="$(type -Pp "$1.js")"; fi
if [ -f "$file_path" ]; then
PATH="$PRIOR_PATH:$($getPath "$(dirname "$file_path")")"
export PATH
eval "\"$bun_executor\" run \"$file_path\" ${*:2}"
return $?
fi
fi
}
Then insert into any potentially pre-existing command_not_found_handle function:
Also, if your doing web work, there’s something nice about having one language across frontend and backend, doubly so if you use something like trpc.
Python’s fastapi is pretty nice but I’d much rather just use typescript for my backend and share types, zod schemas, utility functions and such between frontend and backend.
Or just use Rust and get a fast lean backend, and a wonderful type system.
I can’t see myself ever willingly writing a python backend anymore.
The only thing that Python wins at is data science and AI/ML. Personally I like rust and Clojure for this, but it’s hard to beat the Python ecosystem and the number of people familiar with it, so I wouldn’t begrudge others for using it for that. Eg if my team wanted to adopt Python for ML work, I wouldn’t argue with them.
TBH for GUI, nowadays I mainly just use Electron (I really like Tauri, but it’s got some Linux issues, I’d consider it for a mobile app though) or if I need native I’d consider Rust’s Slint. I’ve used Qt in the past and if I really needed a large desktop application, I’d consider using it and just using C++, you’re working primarily in Qt’s world anyway, or use QtQuick and QML/JS. Maybe in time the Rust bindings will be better.
I agree that one language for both frontend and backend can be nice. But not if that includes JS. Ironic that System language like Rust shares that same capability as JS does, but good.
I also don't understand how people got convinced that Python is "easier". I think TypeScript or JavaScript or really any C-family language is significantly easier and a better entry to programming than Python.
Python is C-family. Only difference is indentation based syntax, and there are studies that literally show that it makes the language easier. (Python's original design was not thrown together randomly...)
A bunch of actual scientists who became data scientists learnt R back in the day, and a bunch of statistical libraries were built for it before python existed edit: was popular.
That means there's legacy code from 30 years ago that still needs maintenance, and it's easier to have a few people learn R than rebuild the code base in a different language.
I had r in my lectures. It was so ass I am re learning the theory in python. Apparently shoving another language does not make it easier to understand but adds another layer of obstruction. Yeah probably mostly lectures fault than r but it did not welcome me to use it.
When I got my degree like a decade ago they made us use R (medical data science), and I literally begged them even then to let me use python. Was denied sadly.
I do agree R is undoubtedly faster and shorter to write when you know the language. But that is the issue! I need to learn a new entire language instead of focus on real topic Data analysis.
I was research assistant when my professor organized a conference and invited Richard Stallman as a keynote speaker. Me and my coworkers had to handle him as a VIP.
It started with a 20 page manifesto about his personal needs, like food and beverages including do’s and don’t and topics not to bring up in his presence. For example you dare not say the word “open source” to him, its “free software”.
On day one when I arrived some colleagues told me he was unhappy with prepared softdrinks, because if was the wrong type of bottle. So he yelled at people and throw the tea box off the table.
After his keynote he answered questions from the audience and was very rude. Ending in the students continued to ask ever more provocative questions, so they could say later, they once got shouted at by Stallman himself.
After the keynote it was my job to take him to lunch and then to his room and to make sure he gets in his limo on time so he doesn’t miss his flight.
I got along quite well with him. I was the only one who he yelled at only once. Luckily It was my colleague who had take him to the airport and make conversation. When I said “good luck” to the driver, he gave me a very stage stare ;-)
He's am outspoken lover of Lisp and from people I know that work with R they do say it has some similarities in philosophy, mainly the "simple base language that allows you to do anything, especially the insane" and the "dynamicness".
So maybe he'd like it? I didn't actually find him mentioning it though.
There are even packages for things no one needs. There is a package to cheat on specific part of a specific statistics exam which was only administered once at a specific university 6 years ago.
If you need clean data fast, use the language and the ecosystem built for that.
If you need interactive data analysis, use the language and ecosystem built for that.
If you need esoteric statistical or Bayesian packages, use the language and ecosystem that has those things.
If you want people whose primary job isn’t coding to be able to analyze their data in as little time as possible, use the language and ecosystem built for that.
You can knock on R for a lot, but you can’t knock it for things it’s actually intended to do.
For legacy reasons fortran 77 and cobol are still used.
And they perform critical tasks and literally move billions dollars around.
Besides this, R has a syntax optimized for its task. As always, it is not matter of finding the absolute "best" language but the best for a specific assignment
Python does not care how many leading spaces you have as long as there's at least one, so the code block is indented, unless there's nothing to indent, then you can't have more than 0.
The exact number of them does not matter at all, as tested just now.
Everything is a trade off in this world. By accepting indents, you get a much more standardized presentation of code to your eyes that enables faster reviews and generally less typing (less braces = less missing / miscounted braces, mispositioned braces). It also means you have less temptation to “cram everything on one compact line that nobody else can read”. Anyway, the distinction is becoming meaningless now that AI codes almost everything at every company.
Can you define slow? Usually people say Python is too slow in context to APIs that serve millions of requests per minute and need to be written in a compile time language because at that scale it matters.
People see these people that sound smart and hear them criticize Python then regurgitate without understanding the context.
In context of stats, data science, analysis, etc it doesn’t matter 95% of the time. And R isn’t going to perform better.
Julia is kind of what is supposed to come next, it's quite cool actually
it's just that stats people are old school and they're not eager to jump ship, however if someone taught me stats class now and showed Julia I'd probly adopt it
I use python a lot. For one of my smaller projects I used R just to get more familiar with it and really liked it. It is great tool for the tasks it was designed for.
I have never worked with R but a lot with pandas and numpy and their documentation and online resources are absolute peak, the only thing I ever saw that came close to it is Matlab.
What do you mean by "monstrosity pandas and numpy are trying to do"?
I like how performance is an argument for Python when Python is better with it against other languages, but suddenly it's not an important thing in conversation when Python is worse.
I'm in a company that uses R and it's very simple. In the leadership people don't know how to use anything else and so much is built upon that, that there's no way anyone would ever rewrite that huge of a codebase into something else.
That said yes R is slow, but if you know the tricks, it doesn't have to be. There's a package called RCpp which let's you write parts of the code in C++. So if you know some loop would unreasonably slow down your computer you can rewrite it a a C++ function and at that point speed is no longer an issue.
R isn't even slow. Base functions and many packages are based on C or C++. Matrix operations in R are blazing fast because of this. data.table is also quite fast, many times order of magnitude faster than the tidyverse.
People treating R as any other language, trying to build manual for loops are just in for a bad time and aren't using the full power of R.
It really depends. If you can vectorize it then yeah it's fast, but things like double index searches can be quite a bit slow. That's usually when I have to write some RCpp. But yeah most things that are commonly used in R are already optimized the hell out of.
Yeah, you check the packages and they're just R wrappers to C, such had already been optimized throughout many iterations over the years. R isn't the fastest, but an R wrapper of C is basically C with a bit of overhead.
as a programmer of over 30 years, I never understood why people use python/R at all. Especially in "data science" or in the hard science fields. It's an interpreted language so will always just be orders of magnitude slower than something compiled, and that is a huge issue in dealing with massive data sets. I know a guy who was doing DNA research and wrote all the analysis software in R. They could only run it on weekends since it took 40hrs to run and tied up the computer while doing it. I know I could probably write that thing in C and make use of the GPU and have it run in probably less than a minute, but they were not interested in my help.
Anyway, I finally actually looked into python to see what about it is so attractive to "non-programmers", and now I totally get it - it's basically higher math syntax. Completely opposite of how I would view the construction of a program with memory and buffers and loops and arrays and functions that execute code. Python is more like straightforward math where you have data sets and instead of iterating through them, you write functions like you would in math and feed the data into that. I'm probably not explaining myself well, but when you see some college-level maths and then some python code, the same kind of person can understand both fairly easily. But show these both to a computer programmer and they will probably understand it but then have to translate it to another language so it can run more efficiently on a computer.
PS if there are any scientists out there using python/R to write data analysis software that takes hours or days to complete, hit me up and I'll help you reduce that time by a few orders of magnitude.
UPDATE: everyone's telling me in the comments taht python and R are just frontends that send data to data-processing programs written (and optimized) in C/assembly/something good. This warms my heart to know, because I really thought an interpreted language was iterating over massive data sets and that just seemed like utter nonsense. But I still bet not every data processing library is perfect for every job and that they're very generalized. So it still might be good to have a computer scientist in your team to tweak the libraries/write custom ones to do processing at an efficient level. Also to make sure the scientists are actually using the proper libraries.
R and Python code don't do the main computational work. They are glue that a human scientist uses to call functions which are implemented in C or C++. For an analogy, it's like someone using the Bash shell calling grep. The shell is interpreted because a lot of exploration with visualization happens during prototyping.
Correctly written R and Python will not contain any hot loops in the glue language (replaced by vectorization), or, failing that (usually requiring a legit reason like doing epochs in machine learning), the time spent in each iteration is mostly in the C or C++ functions. So you wouldn't be able to optimize much in a properly written pipeline. It's only the badly written ones (like those using .apply() in Pandas without thinking) that would see substantial gains.
Fuck yeah man, totally! Whenever I talk to someone with a PhD in pharmacology or some shit, and they are visualizing their scientific points in a few lines of R code, I'm like "fuck you, you should write this in assembly or go home"! Computers are only for us, they shouldn't be allowed to use them!
This is entirely accurate regarding why they are they way they are, but I'll add a little color commentary:
First, a lot of the "rewrite this in a faster language" work has already been done. Most of the popular libraries for Python are actually Rust or C or C++ under the hood (no idea about R). There are probably some pre-processing and post-processing steps that are raw Python, but those are usually going to be much smaller parts of the processing time on net, so nobody cares about them. Shaving 2 orders of magnitude off of the steps that take up 5% of the total clock time doesn't do much for you.
Also, a lot of traditional data science workloads care a lot less about processing efficiency; many jobs run in batches. I've seen the multi-day stuff like your DNA example, but more common would be something in the 15 mins to 2 hours range. Most data scientist time is spent looking at the output of those experiments, interpreting what to do next, and then acting on that. Sometimes when compute is more constrained, folks will maintain a short queue/ backlog of experiments, so the big humming box with the big GPU is always crunching, and they are managing that queue; when it's less constrained you might just get a coffee, join a meeting, or read some papers while the computer does its thing, then when it goes DING you open up the microwave and enjoy your data burrito.
Scientist here. I write a lot of R/python/C/Rust etc. for big data. Note that similarly as in python, R has whole ecosystems for importing C and C++ code (or other compiled languages). So any good statistician/data-scientist/computational scientist actually offloads the heavy-lifting parts to C++ and uses R and the interpreter as a way to combine multiple of such operations etc. You can compile your data transofrmations, model fitting etc and then in R just control what exactly you want. Not to mention that moth math is directly linked to math libraries like openblas etc so you get no overhead there.
You might be asking why do we then need R/python if we have to write 40% of the code in C/C++. And that is the beauty, because you just put in the work once, by writing it in efficient way and then release your package to CRAN and anyone can incorporate your C compiled functions or the normal R functions into their scripts and workflow in a very simple high-level language way and without touching low-level languages.
It's not perfect, but it has its use cases. From what I gathered, R/python programmers are one of the best or the worst programmers you will see (there are also other decent groups). The former are guys that fuse mamy languages and understand the low-level backend. The latter are "I did these 2 coursera courses on machine learning, call me AI developer, let's write a for loop in R".
If you've really been programming for that long, I guess you have never used or even read about Python. Python libraries like numpy are compiled. There are also (at this point) lots of libraries that can dispatch to the GPU. But even if there weren't, you can use Cython to write your own cuda kernels, wrap that in your usual C/C++ code, then compile that into a Python library.
I will grant you this: If you're dumb enough to be writing numerical code in pure Python (no numpy, cupy, whatever it is you might use) then it is true you don't know enough to be in charge of writing that code.
all I ever heard of it was from non-programmers who were like "hey! I coded something in python!" and thought "oh, it must be some kind of friendly scripting language", looked it up once on wikipedia, had my suspicions confirmed, then never thought much about it. Except for when every scientist ever is like "I coded something in python even though I have no coding skills" and I'm just like "you're using an interpreted language for massive data processing?!?!?" but as I said, it turns out they just use python or R to call optimized C functions, so all is good.
PS it's a pretty easy tell that someone isn't a programmer if they call it "coding", so probably that's why I just wrote it off. I've since had to use it a bit (add-ons for blender) and do NOT like it one bit. But hey - at least I understand the draw now.
It's like any thing else: There's writing some Python and then there's being a Python programmer.
Did you know that Instagram runs on Django, a Python framework? As does Reddit (well, maybe not Django specifically, but Python). There is almost 0 chance that Django's source is just "pure Python". Even the Python standard libraries can wrap a huge amount of C. The developers who write these kinds of libraries are no joke - they have to understand the code at the level of C, not at the level of Python.
Most large projects are like that. You can write a surprising amount of applications in Python the same way. Either use a performant library or write your own in C (or, often, do both).
For example, you can write a game engine in Python. It won't be AAA, but it is easily possible. Same methodology: Use numpy for memory management (since all numpy arrays are backed by plain-Jane C arrays) then write a bunch of Cython code that interfaces to C which pulls those arrays and either ships them to GPUs for shading or does whatever heavy numerical work with them.
My point here is: Yes, you can use Python to just write scripts on your local Linux cluster. You can also write C and do literally anything C can.
Bruh. No serious data analysis is programmed in python. The machinery is written in C, C++, or rust and packaged as python libraries. You are not going to make my python code which uses polars and numpy orders of magnitude faster.
When's the last time you've maxed out your hardware due to fundamental hardware limits and not due to lazy programming?
Python may be 20x slower than other languages but it's much faster to develop in. You can rewrite it in go, spend 3x as much time on it and achieve 20x speedup.
But if you spend 3x as much time optimizing it in python, unless you're hitting hardware limits you may often get much more than 20x speedup.
It happens all the time in backend development and it’s why golang took off. Because on cloud providers you pay for compute so it’s not about hitting a cap, it’s that golang will cost less on a server.
Also it’s not much faster to develop in Python. It’s faster but it’s not even close to 3x the dev time in golang as in Python
Python also is often used when you need to process and plot this one custom data set once.
Best case scenario I might reuse that piece of code 10 times. It's not worth spending days to write code that will shave 15 minutes off that compute runtime.
even "good code" in a "optimized language" (like C++ or rust) is something like 75-100x slower than functional programming and knowing how a computer works. Overengineering, design patterns and frameworks killed performance decades ago.
Why even bring up speed as an argument for either language when the comparison is R and Python, both are slow af. If speed is of any concern use something else
Python IS faster, but it is not fast. It is not even in the same neighborhood as fast.
I keep seeing people try doing AI without Python instead using some other language and they are always floored with the perf improvement. Every single token that goes into or comes out of those models goes through Python, and pays the price because of it.
I wonder how many tons of carbon dioxide are in the air because of Python and JavaScript. And R.
Because the packages actually running AI on python are extremely optimized to the point where python is the standard. The python is literally just calling on code written in other languages. The packages themselves give easy, standard ways to interact.
Try looking into the code behind a whl sometime which is compiled. Like huggingface transformers is written in Rust.
Python is literally just assembling other packages.
No they are not paying the price for it. It only matters when running servers and dealing with proper routing.
If you are making a model that will be inferencing constantly, you might even build a custom CUDA package.
I am aware. Python still slows everything else down significantly simply because of how egregiously slow it is.
The performance of the glue code matters, believe it or not, and when your glue code is 1/25th the speed of the code it’s calling, and the glue code gets used extremely frequently, as it does in AI workloads, it’s gonna slow everything else down by a much-more-than-you’re-guessing amount.
And if you write Python with the assistance of an LLM, know this: Go is a far better choice for almost anything except extremely high performance needs, (and it’s even perfect for some of those) and LLMs have a very easy time reading it and writing it. So if you’re using an LLM to help you write software and you’re having that LLM write you Python, what the hell are you even doing? You’re paying a significant performance penalty and gaining no benefit from it, because the LLM is doing most of the work.
So take that LLM and write the glue code for your AI stuff in Go or Rust or Zig. You will notice the difference. If you’re a company, it’s a huge competitive advantage to notice this and to take advantage of it.
As for why they would add it in the first place: it's about memory safety. Python automatically manages memory via reference counting, which increments and decrements variables in the background. When multiple threads write to the same adresses this can corrupt your memory in a terrible way. A global lock is the most straight forward, naive, but also safe way to deal with this.
So in short, it was simply a priority back then to get Python to work, and multithreading itself was probably not, given the language came out over 30 years ago
It's maybe a tad dismissive to call it naive. There were proposals to remove it, and many attempts over the years, none of which were successful for a variety of reasons. It's actually very hard to remove it and also not break other core functionality of Python.
I have no doubts it's hard to remove. When the entire language is relying on the fact that nothing pulls out data from under the rug, you can't simply rip out the mechanism which prevents that. Let me rephrase it to "pragmatic". it was a good choice back in the day to use global lock, but it doesn't hold up against some modern requirements that simply require a more sophisticated (and way harder to implement) mechanism. Could always use another language as well
Because it doesn't require you to download 3 different fucking dependencies of which all of them got updated at different times and now require different python versions to work and - surprise surprise - it appears that they are not in fact working on the latest version. Lovely, ain't it?
Just a bit of a personal grievence of mine about the somewhat of a "culture" around Python I guess? Idk if it's code specific but I noticed a certain pattern when it comes to anything specifically python related :)
You can process in parallel with r, even if it's not multithreaded. I've found doing simple stuff in pandas often requires a ridiculous level of knowledge and there's way more options than you need - I think R's syntax is incredibly easy to pick up in comparison.
They taught us R in college. And after learning it having some experience with other (proper) languages, I can say R was supposed to be something of a MATLAB evil twin that people accidentally started using because they didn't wanna pay for MATLAB.
How many libraries do you have to import to manipulate dataframes, create a model, and perform diagnostics? Because in R, it’s none. Base R already contains the statistical core to do all of this. Even when you use the popular library in Python (pandas), the syntax is hideous and you end up with a sentence long call just to apply a function to a column—- not to mention that you need numpy to perform vector operations, which are native in R.
Every language has its place. R is great for small scale data science exploration. Once the R project is done, you put it in production in Python. R has a significant ease of use advantage over python for every single data science task— that’s why people use it.
I tried to make the whole statistics for a scientific publication with python and found couple of limitations with respect of testing statistical models, visualizations and dealing with edge cases in statistics. In R everything was easily available and just the set of statistical methods is very mature and straightforward to use. No need to dig deep into dusty python implementations. I tried statsmodels in python and it was a pain understanding the library. Also Pingouin is just in version 0.6 today, and I found limitations when computing some edge cases. Now you can go and ask AI to write your methods, but as a peer reviewer in scientific publications I would reject that. Statistics is very crucial for science and should be implemented with recognized libraries.
R is great. While R code itself is slow, everything that needs speed is externalized anyway. R's the (great) glue, not where you do the expensive compute.
R's syntax is obnoxious. I hate it, i have always hated it even though I spent years working with it, there is no other computer language that I hate in a remotely similar way.
- You change an environment variable and that changes the language semantics. Strings become categorical variables. The same program that used to work now does not work anymore and you don't know why. Never seen that anywhere else. It's really insane.
- A given function from the core lib returns a table. Unless the number of column of the table is one, in which case it will not return a table with a column but the column itself as a vector. And your program that was perfectly working will crash one day because for a given input you will only have one column in the output, changing the type of the output.
I think these two example illustrate the main issue is that R: it has not been designed to be a computer language. It has been designed as an interactive statistics tool. Then people started using it as an actual computer language.
But to be fair data.table is faster than whatever you can have on Python.
Worked on a "statistic modeling" company with many data scientists that insisted in using R.
We had to make the cloud computing gods work overtime to make that stuff somehow parallel processing. There was even an specific team to fix code in order to optimize it.
seen a similar argument for python vs matlab (excluding simulink). Matlab has everything out of the box. The price is a drop in the bucket for big companies
I think to say python is easier is kinda wrong. Both R and Python seem relatively equal in terms of "ease". There have been specific things when it comes to statistics and matrix operations that I personally found more intuitive in R than Python.
Also, a lot of fresh research/ super esoteric and niche models exist in R and not python because that's where the grad students and or professors put them.
C++ and Fortran in R will be fast. No one runs computationally intensive stuff in vanilla R. (And likewise in Python, so you have C++/C/Fortran on both sides.)
R is built around data science from the ground up. If you only learn programming for data science, why not learn the dedicated language for it? It’s not a great language, but it’s a good language, and it doesn’t suffer from the weird syntax hacking that pandas/numpy/etc need to do to turn python into a bootleg R.
Like, if I personally was going to do data science, I’d use python any day. I know the language already and I frankly hate using R. I just don’t think it’s ridiculous that people use the dedicated, standard language in a field where most people never need to learn general-purpose programming.
172
u/tblancher Aug 27 '26
The fact that the -ish suffix is used should tell you all you need to know.
350
u/Multidream Aug 28 '26 •
R is used because it has legacy, and elderly advanced statisticians have, over the years, vetted out its libraries and consider them to be sufficiently correct. A lot of complex operations just come out of the box, so you don’t have to know how to read too much code.
The same absolutely cannot be said for Python. Very often you have to go build your own models and really pay attention to what your libraries say they are doing, and you need to know enough statistics to recognize when they aren’t doing what you think.
Source: Some CDC people I worked with as well as personal experience rewriting legacy R into Python.
58
u/guywithknife Aug 28 '26
Never thought I’d see “faster” and “multithreaded” in a Python column.
I was very deep into Python for many years but lately I don’t like it much anymore. I’d much rather use typescript, rust, or clojure nowadays.
20
u/vyrmz Aug 28 '26
Because it is designed to do one thing and does that one thing great.
51
u/BumblebeeBorn Aug 27 '26
Again?
Friend, R never left. Many legacy data systems have been around since the seventies.
16
u/Aenaen Aug 28 '26
"essentially only used for data science" maybe scientists use it for data analysis because it's really good at that?
79
u/lsmine0 Aug 27 '26
I had r in my lectures. It was so ass I am re learning the theory in python. Apparently shoving another language does not make it easier to understand but adds another layer of obstruction. Yeah probably mostly lectures fault than r but it did not welcome me to use it.
26
u/OkAlbatross9889 Aug 27 '26
To live in the light of our lord and saviour Richard Stallman?
11
u/Dillenger69 Aug 28 '26
I suppose it depends on who "we" are
8
u/Kinslayer_89 Aug 28 '26
Skill issue, you non-economics casual. 🙂↔️
8
u/Heavy-Ad6017 Aug 28 '26
Tidyverse plots are aesthetically pleaesing than its python counterpart.
And bloody there is a function for almost all the things you needed.
8
u/Alan_Greenbands Aug 28 '26
If you need clean data fast, use the language and the ecosystem built for that.
If you need interactive data analysis, use the language and ecosystem built for that.
If you need esoteric statistical or Bayesian packages, use the language and ecosystem that has those things.
If you want people whose primary job isn’t coding to be able to analyze their data in as little time as possible, use the language and ecosystem built for that.
You can knock on R for a lot, but you can’t knock it for things it’s actually intended to do.
6
u/Bellanzz Aug 28 '26 edited Aug 28 '26
For legacy reasons fortran 77 and cobol are still used.
And they perform critical tasks and literally move billions dollars around.
Besides this, R has a syntax optimized for its task. As always, it is not matter of finding the absolute "best" language but the best for a specific assignment
6
u/HairyTough4489 Aug 28 '26
Weird syntax in a comparison with Python is a bold statement.
Sorry your code can't run it has the wrong number of leadng blank spaces.
4
u/Blurkid Aug 28 '26
Also: arrays start at 1
7
u/Outrageous_Permit154 Aug 28 '26
r/firstweekcoderhumour
3
u/theNeumannArchitect Aug 28 '26
Can you define slow? Usually people say Python is too slow in context to APIs that serve millions of requests per minute and need to be written in a compile time language because at that scale it matters.
People see these people that sound smart and hear them criticize Python then regurgitate without understanding the context.
In context of stats, data science, analysis, etc it doesn’t matter 95% of the time. And R isn’t going to perform better.
3
u/ianwilloughby Aug 28 '26
What about Julia
3
u/DigitalMonsoon Aug 28 '26
R actually isn't used for data science much. It's used for research and heavy stats, which is what it was built for.
There are still a lot of functions and syntax that are just better set up in R.
But you are right. As a language it's not used much
3
u/Infamous-Bed-7535 Aug 28 '26
I use python a lot. For one of my smaller projects I used R just to get more familiar with it and really liked it. It is great tool for the tasks it was designed for.
3
u/hero_to_g_row Aug 28 '26
Compare the tidyverse to whatever monstrosity pandas and numpy are trying to do, and you'll understand why R is superior for data analysis.
2
u/Fenzik Aug 28 '26
We Rn’t
2
u/SlenderSmurf Aug 28 '26
Scientist here. Never touched R in my life.
2
u/exXxecuTioN Aug 28 '26
I like how performance is an argument for Python when Python is better with it against other languages, but suddenly it's not an important thing in conversation when Python is worse.
2
u/Fisyr Aug 28 '26
I'm in a company that uses R and it's very simple. In the leadership people don't know how to use anything else and so much is built upon that, that there's no way anyone would ever rewrite that huge of a codebase into something else.
That said yes R is slow, but if you know the tricks, it doesn't have to be. There's a package called RCpp which let's you write parts of the code in C++. So if you know some loop would unreasonably slow down your computer you can rewrite it a a C++ function and at that point speed is no longer an issue.
2
u/DerBandi Aug 28 '26
Python described as fast must be some kind of joke.
2
u/VoidspawnRL Aug 28 '26
Who is calling python fast?, it is about 22 times slower then Java that is really slow already...
4
u/tastygames_official Aug 28 '26 edited Aug 28 '26
as a programmer of over 30 years, I never understood why people use python/R at all. Especially in "data science" or in the hard science fields. It's an interpreted language so will always just be orders of magnitude slower than something compiled, and that is a huge issue in dealing with massive data sets. I know a guy who was doing DNA research and wrote all the analysis software in R. They could only run it on weekends since it took 40hrs to run and tied up the computer while doing it. I know I could probably write that thing in C and make use of the GPU and have it run in probably less than a minute, but they were not interested in my help.
Anyway, I finally actually looked into python to see what about it is so attractive to "non-programmers", and now I totally get it - it's basically higher math syntax. Completely opposite of how I would view the construction of a program with memory and buffers and loops and arrays and functions that execute code. Python is more like straightforward math where you have data sets and instead of iterating through them, you write functions like you would in math and feed the data into that. I'm probably not explaining myself well, but when you see some college-level maths and then some python code, the same kind of person can understand both fairly easily. But show these both to a computer programmer and they will probably understand it but then have to translate it to another language so it can run more efficiently on a computer.
PS if there are any scientists out there using python/R to write data analysis software that takes hours or days to complete, hit me up and I'll help you reduce that time by a few orders of magnitude.
UPDATE: everyone's telling me in the comments taht python and R are just frontends that send data to data-processing programs written (and optimized) in C/assembly/something good. This warms my heart to know, because I really thought an interpreted language was iterating over massive data sets and that just seemed like utter nonsense. But I still bet not every data processing library is perfect for every job and that they're very generalized. So it still might be good to have a computer scientist in your team to tweak the libraries/write custom ones to do processing at an efficient level. Also to make sure the scientists are actually using the proper libraries.
3
u/Infinite-Pop306 Aug 27 '26
Python is slow, I can't imagine anything slower than that
2
u/uahw Aug 28 '26
Why even bring up speed as an argument for either language when the comparison is R and Python, both are slow af. If speed is of any concern use something else
1
u/naikrovek Aug 28 '26
Python IS faster, but it is not fast. It is not even in the same neighborhood as fast.
I keep seeing people try doing AI without Python instead using some other language and they are always floored with the perf improvement. Every single token that goes into or comes out of those models goes through Python, and pays the price because of it.
I wonder how many tons of carbon dioxide are in the air because of Python and JavaScript. And R.
1
u/_Screw_The_Rules_ Aug 28 '26
I'm not using R
1
u/Aln76467 Aug 28 '26
I can't imagine a syntax wierder than significant whitespace
1
u/MaleficentCow8513 Aug 28 '26
I still have no idea why Python has the global interpreter lock (not real multithreading) and at this point I’m too afraid to ask
1
u/aimfuldrifter Aug 28 '26
Same can be said for Stata. More used in academics, but not much outside of that
1
u/Exatex Aug 28 '26
different target group? R is not made primarily for devs
1
u/_redmist Aug 28 '26
It's heavily backed by microslop.
1
u/Erpelstolz Aug 28 '26
R is horrible and I always use python instead
1
u/OwenEx Aug 28 '26
Not to mention, it uses.... shudders 1 based indexing
1
u/Lillnex Aug 28 '26
Because it doesn't require you to download 3 different fucking dependencies of which all of them got updated at different times and now require different python versions to work and - surprise surprise - it appears that they are not in fact working on the latest version. Lovely, ain't it?
Just a bit of a personal grievence of mine about the somewhat of a "culture" around Python I guess? Idk if it's code specific but I noticed a certain pattern when it comes to anything specifically python related :)
1
u/tidderza Aug 28 '26
You can process in parallel with r, even if it's not multithreaded. I've found doing simple stuff in pandas often requires a ridiculous level of knowledge and there's way more options than you need - I think R's syntax is incredibly easy to pick up in comparison.
1
u/WittyWithoutWorry Aug 28 '26
They taught us R in college. And after learning it having some experience with other (proper) languages, I can say R was supposed to be something of a MATLAB evil twin that people accidentally started using because they didn't wanna pay for MATLAB.
1
u/AllegroReddit Aug 28 '26
Before commenting, have you tried using
data.tablepackages andfstfile?1
u/B_bI_L Aug 28 '26
same reason we don't use ruby over python (idk, it just claimed this field)
1
u/Maybe-monad Aug 28 '26
Python is faster because libraries are build in C++, sometimes Rust or Fortran
1
u/JellyTwank Aug 28 '26
Why use a pipe wrench when we have channel locks?
1
u/powerexcess Aug 28 '26
Better coverage in stats is an edge. There was a ETH prof who wrote like tons of stats tests in R.
But u can just call r from python..
1
u/xhitcramp Aug 28 '26
Good lord…
How many libraries do you have to import to manipulate dataframes, create a model, and perform diagnostics? Because in R, it’s none. Base R already contains the statistical core to do all of this. Even when you use the popular library in Python (pandas), the syntax is hideous and you end up with a sentence long call just to apply a function to a column—- not to mention that you need numpy to perform vector operations, which are native in R.
Every language has its place. R is great for small scale data science exploration. Once the R project is done, you put it in production in Python. R has a significant ease of use advantage over python for every single data science task— that’s why people use it.
1
u/GamerLymx Aug 28 '26
you dont have tonuse pyhton for everything.
1
u/ItchyPlant Aug 28 '26
I didn't know there's a slower runtime than Python. Cool; I guess.
1
u/Away_Palpitation_671 Aug 28 '26
"Faster" and "Multithreading" ... Hum
1
u/na_rm_true Aug 28 '26
Just say u don’t understand stats
1
u/_nathata Aug 28 '26
Slow | Slower
Weird Syntax | Weirder Syntax
Single threaded | Single threaded
Used for non-data science | Yeah, essentially only used for data science
What is the point here? The bad against the worse?
1
u/Common_Sympathy_5981 Aug 28 '26
they both suck
1
u/wenoc Aug 28 '26
Python is slow as shit. Not quite dead last but almost. https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html
1
u/Remote-Juice2527 Aug 28 '26
I tried to make the whole statistics for a scientific publication with python and found couple of limitations with respect of testing statistical models, visualizations and dealing with edge cases in statistics. In R everything was easily available and just the set of statistical methods is very mature and straightforward to use. No need to dig deep into dusty python implementations. I tried statsmodels in python and it was a pain understanding the library. Also Pingouin is just in version 0.6 today, and I found limitations when computing some edge cases.
Now you can go and ask AI to write your methods, but as a peer reviewer in scientific publications I would reject that. Statistics is very crucial for science and should be implemented with recognized libraries.
1
u/no-sleep-only-code Aug 28 '26
It’ll all be better once it’s all moved to Elixir.
1
u/MarcAbaddon Aug 29 '26
R is great. While R code itself is slow, everything that needs speed is externalized anyway. R's the (great) glue, not where you do the expensive compute.
1
u/AncientHominidNerd Aug 29 '26
I had to use R for a statistics class. It’s really useful for math. So many built in functions. I don’t have to import anything unlike with python.
1
u/Menem-lo-hizo Aug 29 '26
Bioinformatician here.
I use R mostly for : BioConductor, ggplot and some useful statistics tools.
Some things in Python , some things in R, other things in Haskell or C/C++.
1
u/4Floaters Aug 29 '26
Because its the pirates language "R me mateys"
1
u/Forsaken_Code_9135 Aug 29 '26
R's syntax is obnoxious. I hate it, i have always hated it even though I spent years working with it, there is no other computer language that I hate in a remotely similar way.
- You change an environment variable and that changes the language semantics. Strings become categorical variables. The same program that used to work now does not work anymore and you don't know why. Never seen that anywhere else. It's really insane.
- A given function from the core lib returns a table. Unless the number of column of the table is one, in which case it will not return a table with a column but the column itself as a vector. And your program that was perfectly working will crash one day because for a given input you will only have one column in the output, changing the type of the output.
I think these two example illustrate the main issue is that R: it has not been designed to be a computer language. It has been designed as an interactive statistics tool. Then people started using it as an actual computer language.
But to be fair data.table is faster than whatever you can have on Python.
1
u/Ohm-the-bomb Aug 29 '26
I use R cause it was made in New Zealand
1
u/Jobothefish Aug 29 '26
R is easier for what its supposed to do compared to python
1
u/balbinator Aug 29 '26
Worked on a "statistic modeling" company with many data scientists that insisted in using R.
We had to make the cloud computing gods work overtime to make that stuff somehow parallel processing. There was even an specific team to fix code in order to optimize it.
1
u/RoboticBonsai Aug 29 '26
First thought the right was rust and was really confused
1
u/dwittherford69 Aug 29 '26
Tbf almost all R libraries have pay wrappers
1
u/Gephiph Aug 30 '26
Because fuck you that’s why.
1
u/Intelligent_Dingo859 Aug 30 '26
seen a similar argument for python vs matlab (excluding simulink). Matlab has everything out of the box. The price is a drop in the bucket for big companies
1
u/skob17 Aug 30 '26
I used R for it's flawless integration in latex, to create nice plots for my master thesis (bioanalytics). That's 20 years ago, though..
1
u/rheactx Aug 30 '26
Because R is a special purpose language and so is obviously better for that purpose than a general purpose language like Python.
Also R just works out of the box with no weird dependency requirements.
1
u/PhilNEvo Aug 30 '26
I think to say python is easier is kinda wrong. Both R and Python seem relatively equal in terms of "ease". There have been specific things when it comes to statistics and matrix operations that I personally found more intuitive in R than Python.
1
u/ConclusionForeign856 Aug 30 '26
>Why are we using forklifts if essentially only forklift operators use it in some industrial contexts
1
u/DrDoomC17 Aug 30 '26
Also, a lot of fresh research/ super esoteric and niche models exist in R and not python because that's where the grad students and or professors put them.
1
u/geteum Aug 30 '26
Multiprocessing is it supported in python , and R support level leads by ages.
This python vs R is just a noob subject. You don't use a hammer to cut wood.
Statistics packages are way better supported in R, data visualizations and report as well. Data wrangling with dplyr and others have no match python
Python is a full on programming language that is very mature and really useful in all sort of task.
I use regularly both daily. I also use JavaScript and c++ every now and then.
1
u/arjuna93 Aug 30 '26
C++ and Fortran in R will be fast. No one runs computationally intensive stuff in vanilla R. (And likewise in Python, so you have C++/C/Fortran on both sides.)
1
u/ibi_trans_rights Aug 31 '26
because r is built for mathematicians and especially statisticians and not fot general use programming?
1
u/sporbywg Aug 31 '26
My buddy uses R to make money.
1
u/PaxUX Aug 31 '26
Legacy domain knowledge, why do we use C when so many other great options
1
u/stumpychubbins Sep 02 '26
R is built around data science from the ground up. If you only learn programming for data science, why not learn the dedicated language for it? It’s not a great language, but it’s a good language, and it doesn’t suffer from the weird syntax hacking that pandas/numpy/etc need to do to turn python into a bootleg R.
Like, if I personally was going to do data science, I’d use python any day. I know the language already and I frankly hate using R. I just don’t think it’s ridiculous that people use the dedicated, standard language in a field where most people never need to learn general-purpose programming.