4 ms·
On the Design, Implementation, and Use of Laziness in R (2019)
- kkoncevicius 4y agoRoss 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 https://youtu.be/88TftllIjaY?t=1994
- Mathnerd314 4y agoHe 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 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_ 4y agoDo people really use eval? What for? I have used it to unstringify dictionaries but I feel like that barely counts.
- ellisv 4y agoThis 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 4y agoOne 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.
- nomilk 4y agoInteresting 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 https://r4ds.had.co.nz/functions.html#lazy-evaluation
- Mathnerd314 4y agoI think this is the first commit mentioning lazy evaluation: https://github.com/hadley/r4ds/commit/671a21b124d6263436b8fcbfa6dc2bf4d1afa15b https://github.com/hadley/r4ds/commit/671a21b124d6263436b8fc.... It certainly looks like Hadley was the one working on that section of the book.