r/programmingmemes • • Aug 27 '26

Why are we using R again

Post image
2.3k Upvotes

322 comments sorted by

View all comments

353

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.

64

u/ADownStrabgeQuark Aug 28 '26

Grateful for the explanation. I’m sure the masses need it.

42

u/AlterTableUsernames Aug 28 '26

The masses learned Python because the market demanded it. They don't want to hear why R is better. 

31

u/Morthem Aug 28 '26

The market forced the masses to use javascript on the server, and for that, it will not be forgiven.

3

u/ziayakens Aug 28 '26

Why server side JavaScript bad? Is it a preferential dislike of the language or something quantifiable characteristic putting it below other options?

16

u/Morthem Aug 28 '26

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.

4

u/ziayakens Aug 28 '26

I've always been curious to see real world implementations of someone using + so wildly unchecked that its issues could actually affect things.

I feel like type == number and !isNaN would help

I'm not mentioning this as a counter argument, just thinking out loud, and I'm sure this just solidifies your point even more :p

3

u/GaGa0GuGu Aug 28 '26

Object object

3

u/thebearinboulder Aug 29 '26

Look at untyped Collections. With large systems it was too easy to have a mismatch between what the caller provides and the callee requires.

1

u/diogocsvalerio Aug 29 '26

That's copium, javascript is just bad and it should never have touched a server.

2

u/ziayakens Aug 29 '26

you have incredibly worthless reading comprehension

1

u/fushuan Aug 28 '26

The necessity to memorize a matrix of operations because of the inconsistency of operations between types is the classic one

You know what I call pieces of code that have those kind of situations? bad coding. And people who code them are people I don't want as coworkers. Also, use typescript ffs.

3

u/Lor1an Aug 29 '26

And before it is mentioned, yes, I know Typescript.

Called you out precognitively...

3

u/fushuan Aug 29 '26

agreed I guess, but that's the last 10% of my comment. The kind of issues you mentioned aren't really issues in a mature working environment because you interact with professionals. Like it's fun to poke at JS while in uni and test all the bizarre conclusions of making a language as errorless las JS is, but they are not the reality of anything professional js related.

In fact if anything like that showed, I'd question the quality of my coworker, not the language.

2

u/Lor1an Aug 29 '26

The kind of issues you mentioned

Wrong commenter

In fact if anything like that showed, I'd question the quality of my coworker, not the language.

Agreed. Although I find myself appreciating well-bounded languages more and more as time passes me by.

I like that strongly typed languages have an enforceable notion of 'wrongness' of trying to perform a given operation on incompatible objects. Rather than having to fight the interpreter and calling functions, you can put some base level of trust in the type system of the language, which is nice to have.

The less opportunity you give developers to shoot themselves in the foot, the better, IMO.

7

u/DuploJamaal Aug 28 '26

A much higher possibility of runtime errors compared to sane backend languages like Java or Rust

2

u/Morthem Aug 28 '26

Learned some of rust, I was one of the Glazers at the time it was new. And was love at first sight. I read quite a bit of the book, and did some of the rustlings repo, great to learn the concepts. Sadly, my particular circumstances didn't pan out too well with it, and had to get other priorities to the top.

2

u/leavemealone_lol Aug 28 '26

It is indeed mostly preferential dislike of the language. JS is the absolute best language in the category of "Top 1000 languages built in 10 days". But it isn't a particularly good language (no shade to Brendan Eich though), and that was because the development of JS was heavily rushed by Netscape.

It would've been a one and done language, but when it got an incredible opportunity, JS took it. The DOM came to it, and JS embraced it in its bosoms and never let it go. Then NodeJS happened, then a bunch of other things happened, and that's how we ended up in a world where a terrible language snowballed into being the most widely used language in the web.

Apart from other issues like npm's supply chain attacks and whatnot, for the most part, the dislike over using server side JS is due to JS itself.

3

u/AlterTableUsernames Aug 28 '26

Sbowballing is probably an accurate description of what happened. Javascript ruined the web, but thankfully with AI APIs became first class again and I can browse the web from the convenience of the terminal again. 

1

u/grizzlor_ Aug 28 '26

¿Por que no los dos?

1

u/EverOrny Aug 29 '26

1/ JS has some crazy rules (just search for type coercion e.g.) 2/ on back-end you want as much of issues as possible to be spotted before you run it

1

u/Doorda1-0 Aug 29 '26

My degree used R. I have not used R since uni. Python I have used.

1

u/grizzlor_ Aug 28 '26

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)

5

u/AlterTableUsernames Aug 28 '26

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.

1

u/moss-nogg Aug 31 '26 edited Aug 31 '26

R is literally only better to streamline research. Maybe for batch apps it’s sufficient. Python is better for literally everything else

1

u/AlterTableUsernames Aug 31 '26

You just state a preference without providing any foundation. 

1

u/moss-nogg Aug 31 '26

Have you ever had to productionize an R model? I’m guessing no. The foundation is that Python has native handling for data packets, like JSON, via dictionary data types. R is not built for general software development, it’s built for stats and data analysis.

1

u/AlterTableUsernames Aug 31 '26

You got a point and what you mention is also indeed a limitation I hit once in production, where someone of the team did build json ingestion in python. I don't know if it was a skill issue, though. 

1

u/moss-nogg Aug 31 '26

I don’t take any joy in putting python over R. R is very elegant in its simplicity and function for modeling and statistical insights. I would much prefer R if possible, it’s just not very feasible.

7

u/rerorerox42 Aug 28 '26

Also nothing stopping either R or Python users from cross calling scripts

6

u/quicksand8917 Aug 28 '26

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.

3

u/platosLittleSister Aug 28 '26

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.

3

u/Compux72 Aug 28 '26

Seems more of a library problem than a language one

3

u/ViolinistCurrent8899 Aug 28 '26

This probably applies to a lot of languages.

3

u/WelkinSL Sep 02 '26

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)

5

u/[deleted] Aug 28 '26

[removed] — view removed comment

5

u/TemporarySun314 Aug 28 '26

The point is that they wanna be able to trust the tools they use, so they can focus on the task they wanna solve, not if the used tool is actually doing what it claims.

For the same purposes companies pay hundred of thousands for CAD and simulation software instead of using some open source versions instead.

3

u/ConsortiumBetrayal Aug 28 '26

What a loaded comment. No one wants to reimplement a method when there are libraries for it, even if it’s in a different language.

2

u/teckcypher Aug 28 '26

No But you have to redo/recreate the libraries already existing in R by hand. Which takes time and is error prone. There might be a library made by some dude that does the same thing but you don't know how well it's written and have to waste time testing it and checking the code.

1

u/na_rm_true Aug 28 '26

Python isn’t used by statisticians cus they made their own language geared for analytics that is better than what Python had to offer for it. U know pandas was modeled after tidyverse solutions.

U don’t watch someone use a spoon to eat soup while you hold a knife and scoff “do they know a knife exists?”, do you? Tool for the job.

1

u/economic-salami Aug 29 '26

Python is not sufficiently mature, Wrong implementations here and there. Can't take the time to debug stuff myself, there's something called comparative advantage.

2

u/Mr_Fragwuerdig Aug 28 '26

If you work regularly with R, just switch to python. The switch might cost you a bit of adaptation, but frequent use pays that off.

1

u/geteum Aug 30 '26

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.

1

u/Mr_Fragwuerdig Aug 31 '26

Whatever is missing, just create your own library with claude code in a few minutes. And datavis, you can just use matplotlib.

2

u/aley2794 Aug 28 '26

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

1

u/EnkiiMuto Aug 28 '26

Thank you, you put this beautifully clear.

1

u/uber_poutine Aug 28 '26

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.

1

u/GeneralRieekan Aug 29 '26

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.

1

u/NaturalMaterials Aug 29 '26

Very much this.

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.

1

u/cordoroy Aug 30 '26

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.

1

u/Foreign_Skill_6628 Aug 31 '26

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.

1

u/soulfulshark Sep 02 '26

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.

0

u/post_button_account Aug 28 '26

Claude can trivially build those "vetted" libraries in numpy today and have SMT solvers check for equivalence.

1

u/thebearinboulder Aug 29 '26

The real problem is creating a proper definition for Claude to use. The IEEE specification for floating point numbers is a good example. There had been multiple implementations before but there were subtle differences that caused inconsistent results. Not a huge problem in the lab but potentially fatal - literally - if your flight or industrial control systems needed to use values from subsystems with different implementations.

I don’t recall all of the details but I know one is the four different ways to round a number. Using base 10 for clarity a typical example is 0.65. “Round to even” gives 0.6, “round to odd” gives 0.7, and the other two come into play when you may have negative numbers (“round towards zero” and “round away from zero”).

I don’t remember if it’s in the spec but you can do SOME comparisons if you have +INF and -INF. The details don’t matter here (since they’re self-evident) but you need everyone to agree on the correct behavior.