Live data from Hacker News

R adds native pipe and lambda syntax

developer.r-project.org

121–130 of 150 posts

Re: R adds native pipe and lambda syntax

#122
post #109

Earlier quoted context omitted.

There is none and after having used Elixir for a year going back to Python for anything non-trivial input/output parsing feels really cumbersome now. Other comments have mentioned that functional idioms make code harder to read for devs unfamiliar with the concepts but the pipe operator IMHO has no downsides (I am not even sure what it really has to do with funcational programming, other than that it happens to be us…

> Other comments have mentioned that functional idioms make code harder to read for devs unfamiliar with the concepts but the pipe operator IMHO has no downsides (I am not even sure what it really has to do with funcational programming, other than that it happens to be used in more functional languages). What it has to do with functional programming is, first, that it's right side operand is a function, and, second,…

Thanks for the explanation, that makes sense!

Re: R adds native pipe and lambda syntax

#123

Earlier quoted context omitted.

You need a columnar database for good performance. Try DuckDB to ease them into it, it's a columnar SQLite.

Thanks, I’m checking it out, it seems pretty interesting to keep an eye on. Lots of properties that would be useful in our shared computing environment like not requiring root or Docker.

Might also be worth running a local instance of Postgres 13. Super easy to do on Windows without administrator rights.

Re: R adds native pipe and lambda syntax

#124
post #98
post #96

Earlier quoted context omitted.

As someone who is now bouncing back & forth between Python and R on a weekly basis, I've been surprised (after making fun of R sometimes) how much I miss the piping when I leave R for Python. Pandas seems so inflexible by comparison, so nitpicky for little gain. I've been surprised again and again how much dplyr supports near-effortless fluency and productivity. Never really thought I'd be writing that in a public fo…

I'm not an R user, but you should try Julia for data analysis. It seems as flexibility (maybe more) than R, while also having blazing performance. I do like Pandas concept of row indices, which I know Julia (and I believe, R) lack.

I have used Julia a bit and really enjoyed it. The only reason I do not use it for work is lack of libraries. I know I could 'be the change I want to see in the world' and contribute, but given the pace of things at work I cannot fit that in on the company dime at this time...

Re: R adds native pipe and lambda syntax

#126
post #38

Earlier quoted context omitted.

IMO it should be like Fennel and just support `lambda` and `λ`. The latter is not even that hard to type, in virtually any free (libre) OS you can just $ echo ' : "Λ" # GREEK CAPITAL LETTER LAMDA : "λ" # GREEK CAPITAL LETTER LAMDA ' >> ~/.XCompose If you’re limited by a nonfree OS you should be able to patch the problem with free duct tape like Karabiner or AutoHotKey. And in vim you can just *l in insert mode (which…

Now imagine doing that same thing for every system you're programming on. And then imagine having to do it for a million different symbols. I'm sure as hell glad you're not in charge of any of this.

A better solution is just to use the word 'lambda', and let your text editor render it as a lambda symbol if you want (my emacs does this).

Re: R adds native pipe and lambda syntax

#127
post #77
post #40

Earlier quoted context omitted.

> The lambda syntax (\(x) -> x + 1) is similar to Haskell's (\x -> x + 1). The proposed lambda syntax for R is `\(x) x+1` so `\` will just be shorthand for `function`.

The anonymous function change is probably a (small) mistake. function(x) {x + 1} is already logically equivalent to and from some perspectives an arguable syntax improvement on \(x) x + 1 Giving everyone two ways of doing one thing just means the tutorials will be fragmented and beginners even more confused. Tierney mentioned that tidyverse found function(x) too verbose and uses fomula syntax. Given how tidyverse oft…

If you’re worried about giving programmers too many options, R is already a nightmarish lost cause...

Re: R adds native pipe and lambda syntax

#128

That backslash syntax is pretty funky, but then again all of R is a little funky. Very nice addition to the language though!

I must say I don't really see the point, given that function() does the same thing, with only a few more characters.

that's a lot more characters. useless, unnecessary characters I might add.

Re: R adds native pipe and lambda syntax

#129

Earlier quoted context omitted.

This, along with inferior metaprogramming affordances, is the biggest reason pandas will never be as productive an analyst tool as R's dplyr. In R you can pipe anything into anything. In pandas you're stuck with the methods pandas gives you. This is also why pandas API is so bloated. A lot of pandas special-case functionality, like dropping duplicate rows, can be replicated in R by chaining together more flexible and…

Pandas does have the .pipe() method [0], which allows you to put an arbitrary callable in a method chain, but it is a bit more cumbersome than in R. [0] https://pandas.pydata.org/pandas-docs/stable/reference/api/p...

Except you can't actually use it, because it will kill the performance of your program.

Re: R adds native pipe and lambda syntax

#130

Earlier quoted context omitted.

Now imagine doing that same thing for every system you're programming on. And then imagine having to do it for a million different symbols. I'm sure as hell glad you're not in charge of any of this.

A better solution is just to use the word 'lambda', and let your text editor render it as a lambda symbol if you want (my emacs does this).

No, that's a shithouse solution.

Everyone that doesn't have a fancy IDE now has 6-8 extra useless characters for something that should be syntax.

Post reply on HN