
Ruby 2.0.0 feature freeze - ujeezy
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/46258
======
aoe
So, anyone has a list of the major changes coming in 2.0?

Btw, slightly misleading title. It kind if implies that 2.0.0 is out.

~~~
JohnBooty
According to Matz last year,

"The version number goes up to 2.0 but the changes are rather small. Smaller
than the ones we made in 1.9."

[http://www.rubyinside.com/ruby-2-0-implementation-work-
begin...](http://www.rubyinside.com/ruby-2-0-implementation-work-begins-what-
is-ruby-2-0-and-whats-new-5515.html)

Here's a Quora thread with links to a presentation by Matz and a summary by
Yehuda Katz: [http://www.quora.com/Ruby-programming-language/What-are-
the-...](http://www.quora.com/Ruby-programming-language/What-are-the-major-
changes-in-Ruby-2-0)

"Language improvements:

\- Named arguments.. 1.step(by: 2, to: 10) { ... }

\- Selector namespaces (unclear to me whether this differs from refinements as
described by Katz)

\- Multiple inheritance

Interpreter Improvements:

\- Incremental performance improvements over 1.9's VM

\- Better compatibility with non-unix environments and small/constrained
devices (embeddable)

\- Sandboxed VM's (VM per thread)"

Matz's presentation:
[http://www.youtube.com/watch?feature=player_embedded&v=t...](http://www.youtube.com/watch?feature=player_embedded&v=t9LMOydfc4k)

Yehuda's summary of "refinements":
[http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-
pra...](http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/)

~~~
tenderlove
> Named arguments

yes, though it's basically an optional argument hash. AFAIK, you can't do
_required_ named arguments without weird hacks, or specifically checking the
arguments. For example:

    
    
        irb(main):007:0> def foo(bar: bar, baz: Object.new); [bar, baz]; end
        => nil
        irb(main):008:0> foo(bar: 1)
        => [1, #<Object:0x007fcaa40db4e0>]
        irb(main):009:0> foo(baz: 1)
        NameError: undefined local variable or method `bar' for main:Object
        	from (irb):7:in `foo'
        	from (irb):9
        	from /Users/aaron/.local/bin/irb:12:in `<main>'
        irb(main):010:0>
    

This hack makes the "bar" parameter required, but only because the value is
evaluated when the method is called, and you get a NameError (rather than an
ArgumentError).

> Selector namepaces

yes, but it's called refinements. You can see how they're used here:
[https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refin...](https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb)
(sorry for the link to a test, I'm feeling lazy ;-) )

> Multiple inheritance

Sorry, there won't be multiple inheritance.

> Incremental performance improvements over 1.9's VM

yes, ko1 has been working on removing / optimizing bytecodes in the VM.

> Better compatibility with non-unix environments and small/constrained
> devices (embeddable)

I don't know of any work on this other than mruby, which isn't MRI.

> Sandboxed VM's (VM per thread)

nope. <https://bugs.ruby-lang.org/issues/7003>

Other stuff:

* DTrace probes

* Better _within_ ruby tracing <https://bugs.ruby-lang.org/issues/6895>

I run edge ruby against rails daily. The main incompatibilities I've hit in
Ruby 2.0 are what methods respond_to? searches (I've blogged about that here:
[http://tenderlovemaking.com/2012/09/07/protected-methods-
and...](http://tenderlovemaking.com/2012/09/07/protected-methods-and-
ruby-2-0.html) ), and the `Config` constant has been removed (which is
sometimes an issue for C extensions).

 __EDIT __

Just thought of this for the required args:

    
    
        irb(main):001:0> def foo(bar: (raise ArgumentError), foo: Object.new); [bar, foo]; end
        => nil
        irb(main):002:0> foo(bar: 1)
        => [1, #<Object:0x007fc65a882f48>]
        irb(main):003:0> foo(foo: 1)
        ArgumentError: ArgumentError
        	from (irb):1:in `foo'
        	from (irb):3
        	from /Users/aaron/.local/bin/irb:12:in `<main>'
        irb(main):004:0>
    

You could probably define a private method like `required` or some such, like
this:

    
    
        irb(main):001:0> def required(name); raise ArgumentError, "missing param: %s" % name; end
        => nil
        irb(main):002:0> def foo(bar: required(:bar), foo: Object.new); [bar, foo]; end
        => nil
        irb(main):003:0> foo(bar: 1)
        => [1, #<Object:0x007fcfea143338>]
        irb(main):004:0> foo(foo: 1)
        ArgumentError: missing param: bar
        	from (irb):1:in `required'
        	from (irb):2:in `foo'
        	from (irb):4
        	from /Users/aaron/.local/bin/irb:12:in `<main>'
        irb(main):005:0>

~~~
InclinedPlane
> > Multiple inheritance

> Sorry, there won't be multiple inheritance.

Thank all that is holy in the world.

~~~
angersock
Amen to that.

C++ pretty much ruined that party for everyone.

------
jfaucett
rename title, 2.0.0 is still months away. This is just a requested feature
freeze.

~~~
briancurtin
How is "Ruby 2.0.0 feature freeze" an inaccurate title?

I ask because it has been common to use that terminology with Python releases
for as long as I can remember, as well as with other projects I've worked on
or am familiar with. We would have said the CPython 3.3.0 feature freeze was
in June, with the final release happening last month.

~~~
arrogant
The title at the time of jfaucett's comment was just "Ruby 2.0.0".

------
evolve2k
Oh, would love to have had .present? added to ruby 2.0

------
ksec
Any performance and memory usage improvement benchmarks? I was hoping Ruby 2.0
will no longer be dog slow...

------
Perceptes
Will the GIL still be present in 2.0?

~~~
Spakman
It'll be there.

