[HN Gopher] On the Design, Implementation, and Use of Laziness i...
___________________________________________________________________
On the Design, Implementation, and Use of Laziness in R (2019)
Author : bmacho
Score : 29 points
Date : 2023-03-26 09:28 UTC (13 hours ago)
(HTM) web link (arxiv.org)
(TXT) w3m dump (arxiv.org)
| kkoncevicius wrote:
| Ross Ihaka said in one talk that lazy evaluation would be one of
| the things he would remove if he was re-writing R today.
|
| https://youtu.be/88TftllIjaY?t=1994
| Mathnerd314 wrote:
| He said it's one of the obvious things to remove if you're
| trying to make a faster, more static language. And apparently
| he got Brendan McArdle to implement this list of features, and
| the resulting language was 10x faster on some toy examples. It
| reminds me of the hiphop talk where they list why PHP is slow
| (https://youtu.be/p5S1K60mhQU?t=634). Of course Facebook then
| went on to release the Hack language.
|
| But it's not clear to me that he'd necessarily remove these
| features in an R clone. For example, eval is one of the
| features to remove. Python has eval, and I think many people
| use it, because it's convenient. Although it's hard to
| implement in a static language, that isn't a good reason to
| remove it in a dynamic scripting language. A PEP to remove it
| would probably get shot down immediately.
| fauxpause_ wrote:
| Do people really use eval? What for? I have used it to
| unstringify dictionaries but I feel like that barely counts.
| nomilk wrote:
| Interesting note (most probably from Hadley, although would need
| to confirm via commit history on the open source book the quote
| comes from):
|
| > (Lazy evaluation) is an important property of R as a
| programming language, but is generally not important when you're
| writing your own functions for data analysis.
|
| Source: _R for Data Science_
| https://r4ds.had.co.nz/functions.html#lazy-evaluation
| Mathnerd314 wrote:
| I think this is the first commit mentioning lazy evaluation: ht
| tps://github.com/hadley/r4ds/commit/671a21b124d6263436b8fc....
| It certainly looks like Hadley was the one working on that
| section of the book.
| ellisv wrote:
| This has the obvious measurement bias of only looking at
| packages, and not a wider sample of user code.
|
| But I think it's likely that most users, and most code, are
| entirely unaware of lazy evaluation.
| fn-mote wrote:
| One exception: "modern" tidyverse users.
|
| Astract example: a function that takes in a "bare" column name
| and later "embraces" it in a data frame context.
|
| Concrete example: this function filters for c being nonzero,
| and uses lazy evaluation: function (df,c) {
| df |> filter({{c}} != 0) }
|
| That's an acceptable level of complexity for "not really
| programmer" R users to get something done. Whether or not they
| actually understand what they are doing under the hood? That's
| a different issue.
___________________________________________________________________
(page generated 2023-03-26 23:02 UTC)