

Ruby 2.2.0-preview1 Released - petercooper
https://www.ruby-lang.org/en/news/2014/09/18/ruby-2.2.0-preview1-released/

======
tbrock
Ruby is still my favorite programming language to use for a project. It
doesn't have the immediate approachability of python but if you put in the
effort to understand and accept it's quirkiness you fall in love. I hope it
continues to move forward as far as performance goes so people will continue
to use it, not just mostly for prototypes, but beyond. Ruby 2.2 is a great
step.

~~~
yxhuvud
What quirkiness are you referring to? I tend to find python more quirky but
then I've got a lot more experience with Ruby.

~~~
muchabi
Also curious here. I too find Ruby more consistent/predictable than Python.

Ruby is my main/favorite language, but I was exposed to Python first and used
it a lot more for work/school, so it's not an experience thing here.

------
why-el
Very impressive results with the new GC for symbols. Of 100,000 created, a
`GC.start` got them down to about 2000.

------
ramigb
It's a "weird feeling" to see a framework mentioned in a language update! it
shows you that like Python has "one obvious way to do things" Ruby has one
obvious framework, i can't see PHP 6.0 released and codeigniter/cake/any other
framework mentioned in the release, correct me i'm wrong!.

~~~
why-el
It really isn't. They mentioned Rails because it will be the biggest winner
from their new GC that also collects symbols (Rails is a heavy user of
symbols). No harm in mentioning some of the beneficiaries of the change, as
long as that change is not unfairly impacting other projects. Good move from
Matz and co.

~~~
ramigb
Never said it's a bad move, i love Rails and i love Ruby as well, it was just
the first time i see a framework directly mentioned in a language changelog.

~~~
rubiquity
ruby-core has a history of making sure Rails does not guide the direction of
Ruby the language. Most of the time, advancements to Ruby the language will
always have a positive impact on Rails the framework. Sometimes these changes
to Ruby the language come to light because of Rails the framework. It's a very
healthy relationships between the two.

------
riffraff
My fav feature:

    
    
       * min, min_by, max and max_by supports optional argument to return multiple elements.
    

Assuming this does The Right Thing (i.e. uses fixed space) I always wanted it.

~~~
repsilat
> uses fixed space

I guess the "normal" way to write this is with a heap? For `min`, I guess the
algorithm is something like,

    
    
      min(items, k=1):
        h = max_heap(items[:k])
        for i in items[k:]:
          h.push(i)
          h.pop_max()
        return sorted(h)
    

It isn't asymptotically slower than the normal algorithm for k=1, it doesn't
need to make multiple passes over the data, and it doesn't mutate the original
data structure, so it's a pretty sensible and natural extension to put in.

~~~
riffraff
yes, it's not hard (although I seem to recall mysql only implemented "limit"
like this in v5.6), it's just that if it's not readily available people (well,
me) tend to fall back to sort+first(n), which can be quite wasteful.

------
stevekl
I always have a mixed feeling about ruby. The "magic-ism" of ruby is something
that I just cannot deal with.

"require" gives you methods that appear out of nowhere (unlike other language
where they are name spaced), method call without perens (so what is an
attribute, what is a method call)

All of these look nice at first but kills maintainability later

~~~
regularfry
> so what is an attribute, what is a method call

It's all method calls. Attributes don't really exist.

~~~
epidemian
> It's all method calls.

Probably nitpicking, but it's actually all messages. An object might not have
a method "foo", but happily respond to the "foo" message.

~~~
throwaway0010
And the object responds to the "foo" message by calling a method.

The difference is whether we're discussing the invocation or the response.
OP's usage of method isn't incorrect in this case if it's discussing the
response. It is true that all message responses (including accessors) are
implemented using methods.

~~~
epidemian
> It is true that all message responses (including accessors) are implemented
> using methods.

An object can respond to a message even though it doesn't have a method with
that name. A classic example are Rails' dynamic finders:

    
    
      User.methods.include?(:find_by_name)
       => false
      User.respond_to?(:find_by_name)
       => true

~~~
dragonwriter
> An object can respond to a message even though it doesn't have a method with
> that name.

Sure, by using a _different_ method (method_missing); its still all method
calls.

------
dakull
This looks awesome so far - kudos to the team. I also started benchmarking it
just for fun[0]

[0] -
[http://marianposaceanu.com/articles/ruby-2-2-0-preview-1-qui...](http://marianposaceanu.com/articles/ruby-2-2-0-preview-1-quick-
rails-benchmarks)

------
stanislavb
Waiting for Christmas...

------
atmosx
> Because if this Rails 5.0 will be released for Ruby [...]

I guess there's a typo: s/if/of

------
ksec
Now benchmarks Benchmarks...

