DEV Community

Any thoughts on Ruby 2.6?

Ben Halpern on December 24, 2018

Ruby 2.6.0-rc2 has been released and the stable should be around the corner.

This is a nice post going over some of the new stuff.

Any thoughts here?

Collapse
 
rhymes profile image
rhymes

Yes to union, the new merge reminds me of Object.assign in JS, not psyched about the breaking change and this feature here seems unnecessary and confusing:

double = proc { |x| x * 2 }
increment = proc { |x| x + 1 }
(double >> increment).call(2) #=> 5
(double << increment).call(2) #=> 6

Did we really need an operator to invert the order of composition of anonymous functions? 🧐

Why not simply invert the functions?

(double >> increment).call(2) #=> 5
(increment >> double).call(2) #=> 6

The thing I find more interesting is not mentioned in the article, the preview JIT compiler. It's not enabled by default but it could speed up long lived processes like web apps. It's described on ruby-lang.org -> Ruby 2.6.0-rc2 Released

Collapse
 
ben profile image
Ben Halpern

From the linked article, this is classic Ruby:

non-ASCII constant names}

Constant names can now start with non-ASCII capital letters. I am not sure how useful this is, but you can do funny things like:

class Σ♥²; end

😄

Collapse
 
rhymes profile image
rhymes

Well, in theory you're supposed to have tests so failing tests should start breaking. But yeah, it's going to take work from some gem authors. The good thing is that the change has been in Ruby trunk for seven months so people might have already started fixing their code.

In their defense, Rubysts were relying on the wrong behavior on a feature badly implemented. See the issue on the bug tracker.

I don't know about the example you made, I don't think I've ever used the case statement :-D

 
rhymes profile image
rhymes

Very true. The thing is you don’t fix it. You say “the implementation of that sucks, but bear with it.” Or you deprecate the behaviour, print boring warnings for at least one major version further and only then you change it.

Yeah, true that, they should have put warning signs everywhere for 2.6 and maybe fixed it in 2.7 (or Ruby 3?).

 
rhymes profile image
rhymes

I agree you shouldn't test core functionalities but if something that returns true suddenly returns false some tests will break. If they don't maybe they're not writing the right tests.

I feel like a maintainer of a gem should keep an eye on the changelog of the language the library is written on. At least to check if there are new features that one can take advantage of.

Anyhow, I don't like either but I don't think it's an insane idea. There's no right time to fix a bad behavior people built their libraries on, unfortunately

Collapse
 
ben profile image
Ben Halpern

🙃