top | item 46051391

(no title)

aorist | 3 months ago

> Examples include converting boxplots into violins or vice versa, turning a line plot into a heatmap, plotting a density estimate instead of a histogram, performing a computation on ranked data values instead of raw data values, and so on.

Most of this is not about Python, it’s about matplotlib. If you want the admittedly very thoughtful design of ggplot in Python, use plotnine

> I would consider the R code to be slightly easier to read (notice how many quotes and brackets the Python code needs)

This isn’t about Python, it’s about the tidyverse. The reason you can use this simpler syntax in R is because it’s non-standard-evaluation allows packages to extend the syntax in a way Python does not expose: http://adv-r.had.co.nz/Computing-on-the-language.html

discuss

order

blubber|3 months ago

"The reason you can use this simpler syntax in R is because it’s non-standard-evaluation ..."

So it actually is about Python vs R.

That said, while this kind of non-standard evaluation is nice when working interactively on the command line, I don't think it's that relevant when writing code for more elaborated analyses. In that context, I'd actually see this as a disadvantage of R because you suddenly have to jump through loops to make trivial things work with that non-standard evaluation.

_Wintermute|3 months ago

The increasing prevalence of non-standard evaluation in R packages was one of the major reasons I switched from R to python for my work. The amount of ceremony and constant API changes just to have something as an argument in a function drove me mad.

robot-wrangler|3 months ago

>> I would consider the R code to be slightly easier to read (notice how many quotes and brackets the Python code needs)

Oh god no, do people write R like that, pipes at the end? Elixir style pipe-operators at the beginning is the way.

And if you really wanted to "improve" readability by confusing arguments/functions/vars just to omit quotes, python can do that, you'll just need a wrapper object and getattr hacks to get from `my_magic_strings.foo` -> `'foo'`. As for the brackets.. ok that's a legitimate improvement, but again not language related, it's library API design for function sigs.

tmtvl|3 months ago

The right way is putting the pipe operator at the beginning of the expression.

  (-> (gather-some-data)
    (map 'Vector #'some-functor)
    (filter #'some-predicate)
    (reduce #'some-gatherer))
Or for those who have an irrational fear of brackets:

  ->
    gather-some-data
    map 'Vector #'some-functor
    filter #'some-predicate
    reduce #'some-gatherer

medstrom|3 months ago

IIRC, putting pipe operator `|>` at end of line prevents the expression from terminating early. Otherwise the newline would terminate it.

jampekka|3 months ago

I wonder what the last example of "logistics without libraries" would look like in R. Based on my experience of having to do "low-level" R, it's gonna be a true horror show.

In R it's often that things for which there's a ready made libraries and recipes are easy, but when those don't exist, things become extremely hard. And the usual approach is that if something is not easy with a library recipe, it just is not done.

debtta|3 months ago

Python: easy things are easy, hard things are hard.

R: easy things are hard, hard things are easy.

m000|3 months ago

The way you describe it, can we say that R was AI-first without even knowing?

dm319|3 months ago

> This isn’t about Python, it’s about the tidyverse.

> it’s non-standard-evaluation allows packages to extend the syntax in a way Python does not expose

Well this is a fundamental difference between Python and R.

debtta|3 months ago

The point is that the ability to extend the syntax of R leads to chaos and mess (in general) but when used correctly and effectively in the tidyverse, improves the experience of writing and reading code.

npalli|3 months ago

Python is nothing without it’s batteries.

pphysch|3 months ago

The design and success of e.g. Golang is pretty strong support for the idea that you can't and shouldn't separate a language from its broader ecosystem of tooling and packages.

jskherman|3 months ago

Python is its batteries.

1vuio0pswjnm7|3 months ago

What language is used to write the batteries

throwaway2037|3 months ago

I hear this so much from Python people -- almost like they are paid by the word to say it. Is it different from Perl, Ruby, Java, or C# (DotNet)? Not in my experience, except people from those communities don't repeat that phrase so much.

The irony here: We are talking about data science. 98% of "data science" Python projects start by creating a virtual env and adding Pandas and NumPy which have numerous (really: squillions of) dependencies outside the foundation library.

getnormality|3 months ago

It's not about Python, it's about how R lets you do something Python can't?

evolighting|3 months ago

R is more of a statistical software than a programming language. So, if you are a so-called "statistician," then R will feel familiar to you

UniverseHacker|3 months ago

No, R is a serious general purpose programming language that is great for building almost any type of complex scientific software with. Projects like Bioconductor are a good example.