DEV Community

loading...

Discussion on: Ruby 2.7: The Pipeline Operator

Collapse
citizen428 profile image
Michael Kohl • Edited

Like many other of the proposed 2.7 changes (pattern matching, anonymous block arguments) this is controversial and seems a bit pointless:

  • Anonymous block arguments look like instance variables even though they are not and don't save much typing ({ |a, b| a + b } vs { @1 + @2 }).
  • Pattern matching is somewhat nice, but IMHO works better in languages where you can overload functions/methods, which replaces a lot of conditionals in the body with pattern matched arguments.
  • The "pipeline operator" (|> in Elixir/Ocaml/F#, ->/->> in Clojure) makes a lot more sense in languages where it turns code from something like f(g(h(x)))) into x |> h |> g |> f which reduces cognitive overhead by making order of application clearer. This is generally not a problem in Ruby where the x.h.g.f form already takes care of it.

I've been an ardent Rubyist since 2004 and involved in running both the regular meetup and a RubyConf in Bangkok. But I haven't used Ruby for any new private projects in about a year now and looking at the recent direction the language is taking this probably won't change any time soon.

Collapse
rubyfeedback profile image
rubyFeedback

Anonymous block arguments look like instance variables even
though they are not and don't save much typing
({ |a, b| a + b } vs { @1 + @2 }).

You pick a single example and discount other examples.

I already refuted this in issue trackers, so I will refute it here too, just so that people don't singularize on these erroneous claims made by people who write clearly in the sense of how they dislike something.

Consider:

array.each {|cat, dog, hare, some_strange_name_here, some_other_strange_name|

In the middle of writing code, you add:

pp dog
pp some_strange_name_here

And in these examples, it is so much easier to write:

pp @4
pp @5

Since you decided to focus on only a trivial example, I am happy to extend your example with another one.

I am getting hugely tired of people being so single-minded.

It is totally fine to dislike a change; for example, I don't like the |> pipe operator and will not use it. But I do not think it is good to be critical AND only mention what you dislike, without finding ALL possible advantages/disadvantages.

But I haven't used Ruby for any new private projects in about a
year now and looking at the recent direction the language is
taking this probably won't change any time soon.

I am writing lots of ruby and while I dislike some of the changes,
it is not as if you are forced to use any of it. Nor would this
affect the way I write code either. I am just selective in what I
use and what I don't use.

I find it strange of you to consider wanting to use ruby or not based on new features. That is already a HORRIBLE use case if you don't use the language as-is. None of the changes made me stop writing ruby code altogether - I just don't use the changes I dislike. Are you FORCED to use anything that is added?

There is only one thing I agree with - the explanation part, which is often missing or incomplete. I think it is fine to make changes; sompe people will always dislike something. It is still important to explain, in english, what is added, why and so forth - otherwise the language is a black box. Discussions at the ruby dev meeting are also summarized in english, which is good - this should be for all changes that are discussed in japanese too, because many people do not understand japanese. I don't for instance, so I depend on english.

Collapse
citizen428 profile image
Michael Kohl • Edited

array.each {|cat, dog, hare, some_strange_name_here, some_other_strange_name|

If your blocks take this many arguments your code may have other issues.

I find it strange of you to consider wanting to use ruby or not based on new features.

I don't. I haven't picked it up for private projects for many reasons, but to me a lot of the new changes feel out of place and not like the language I fell in love with 15 years ago.

I am getting hugely tired of people being so single-minded.

You also conveniently ignored the part where I mentioned I'm still co-organizing a monthly Ruby meetup and a conference later this year. 🤷🏻‍♂️

BTW, if you often find yourself this upset about stranger's opinions on the Internet I recommend camomile tea, mindfulness practice and going outside more.

Collapse
johncarroll profile image
John Carroll

I already refuted this in issue trackers

I'll point out the obvious, you can't refute an opinion. You've just presented a counter-opinion.