Live data from Hacker News

New Features in Ruby 2.4

blog.blockscore.com

31–40 of 76 posts

Re: New Features in Ruby 2.4

#31
post #2

Some of these are pretty amazing, like the `digits` method and the new OptionParser functionality (which seems to be a sort of standard library equivalent to doctopt!). That being said, I can't help but shake my head at the section about "multiple assignment of conditionals: "You can now assign multiple variables within a conditional...You probably shouldn’t do that though." Am I alone and thinking that it's a little…

I like the feature, but just for understanding, will the assignment always be truthy if any of the assigned variables are set? The example is

    branch1 =
      if (foo, bar = %w[foo bar])
        'truthy'
      else
        'falsey'
      end

    branch2 =
      if (foo, bar = nil)
        'truthy'
      else
        'falsey'
      end

    branch1 # => "truthy"
    branch2 # => "falsey"

What about

    branch3 =
      if (foo, bar = ['foo', nil])
        'truthy'
      else
        'falsey'
      end

?

Re: New Features in Ruby 2.4

#33
post #30

These are all great but when are we getting optional typing? If the js ecosystem wasn't a clown operation my language of choice would be typescript instead of ruby.

It's not on agenda and it will never happen. There are so many languages with fine typing, why break a dynamic one by adding stuff to it?

I think the person you are replying to will disagree that it is "breaking" the language.

Re: New Features in Ruby 2.4

#34
post #27

Ruby is the first language I really like. The core concept of the language is small, just not easy to get, but the change on how to programming is significant. Sadly, Ruby is not the language for the multi-core world, and many advantages of using it is disappearing. Although Ruby is changing, 2.3, 2.4, maybe 3.0, but what's the difference?

> Ruby is not the language for the multi-core world, and many advantages of using it is disappearing Not really; it depends on the audience. The Ruby audience is still mainly Rails development, whose paradigm is multi-process.

Rails is an excellent framework, but it isn't a feature of Ruby. When some other frameworks are rising, Ruby can lose quickly.

Re: New Features in Ruby 2.4

#35
post #19

Will this be the last release before 3? Is there a defined schedule for 3 yet? Or just "When it's done"?

the target ETA for ruby 3 is "this decade" or 2020, as per http://confreaks.tv/videos/rubyconf2015-keynote-and-q-a-matz

so probably no, this won't be the last release before ruby 3.

Re: New Features in Ruby 2.4

#36
post #3

digits method just saved code-golfers 20 characters. `num.to_s.split(//).map(&:to_i)` => `num.digits`

As a golfer, that code would have already been golfed down to:

num.to_s.chars.map &:hex

So digits only saves 14 characters (22 if reverse is really necessary). But usually we would actually be doing something with the digits instead of just getting them, so the method may save even less.

For example, for finding digit sums, the new digits and sum methods give us the efficient:

num.digits.sum

But for numbers up to 5 digits (or digit sums up to 47) we can already do:

num.to_s.sum%48

which is just 1 character longer.

Re: New Features in Ruby 2.4

#37
post #2

Some of these are pretty amazing, like the `digits` method and the new OptionParser functionality (which seems to be a sort of standard library equivalent to doctopt!). That being said, I can't help but shake my head at the section about "multiple assignment of conditionals: "You can now assign multiple variables within a conditional...You probably shouldn’t do that though." Am I alone and thinking that it's a little…

Let's not forget when PHP added GOTO recently.

Re: New Features in Ruby 2.4

#38
post #27

Ruby is the first language I really like. The core concept of the language is small, just not easy to get, but the change on how to programming is significant. Sadly, Ruby is not the language for the multi-core world, and many advantages of using it is disappearing. Although Ruby is changing, 2.3, 2.4, maybe 3.0, but what's the difference?

Have you used concurrent-ruby?

https://github.com/ruby-concurrency/concurrent-ruby

Re: New Features in Ruby 2.4

#39
post #27

Ruby is the first language I really like. The core concept of the language is small, just not easy to get, but the change on how to programming is significant. Sadly, Ruby is not the language for the multi-core world, and many advantages of using it is disappearing. Although Ruby is changing, 2.3, 2.4, maybe 3.0, but what's the difference?

Have you used concurrent-ruby? https://github.com/ruby-concurrency/concurrent-ruby

Does this fix the issue that is the GIL?

Re: New Features in Ruby 2.4

#40
Great to see my favorite language evolving! I also use various lisps, Java, Haskell, Typescript, JavaScript, Python, etc., but I am happiest when coding in Ruby.

Unfortunately, most of what I do now is machine learning, and Python wrappers for underlying C++ code have by far more support than Ruby. (Ruby does have some great ML projects and libraries though).

Post reply on HN