Wild &
Weird Ideas
  An overview of Ruby 1.9
 LRUG 10th december 2007
What is it?

• The last odd-numbered release before
  Ruby 2.0
• “Wild &RubyConf Ideas”
           Weird
   - Matz,       ...
When is it coming out?

Christmas
  2007
The Biggest Change


      becomes
The Biggest Change




   ... but let’s not complain
    ours isn’t much better!
The Real Biggest Change



  YARV
YARV
         3 Things It Means To Us
1. New developer
  •   not matz-bound
2. Better Performance
  •   in places
3. Nativ...
Other Changes
                                                                                                         Mod...
Other Changes



 a lot
New Syntax
irb> c = -> (a, b) {a.times{puts b}}
=> #<Proc:0x48adf0@(irb):34 (lambda)>
irb> c.call(2, 'hello')
hello
hello
=> 2
irb> c = ->(a, b = ‘muz’) do
irb*   a.times{puts b}
irb> end
=> #<Proc:0x52f17a@(irb):50 (lambda)>
irb> c.call(1)
muz
=> 1
irb> c = ->(a, b, &c) do
irb*   a.times{c.call(b)}
irb> end
=> #<Proc:0x65cd68@(irb):36 (lambda)>
irb> c.call(2, 'hello'){...
irb> def lolmatz(n1, v=‘SPESIFY’, n2)
irb>   “IN YR #{n1} #{v}IN YR #{n2}”
irb> end
=> nil
irb> lolmatz(‘RUBY’,’LANGUJ’)
=...
irb> c = -> (a, b) {a.times{puts b}}
=> #<Proc:0x48adf0@(irb):34 (lambda)>
irb> c.(2, 'hello')
hello
hello
=> 2
irb> num = [1,2,3]
irb> bers = [4,5,6]
irb> numbers = [*num, *bers]
=> [1,2,3,4,5,6]
Changes to
the Standard
   Library
String
• Encoding    aware
  •   methods are char, not byte, based now

  •   open(‘blah.txt’, ‘r:utf-8’)

  •   # -*- cod...
Enumerable
• Enumerable::Enumerator part of
  core
• Enumerable methods without a block
  •   [1,2,3].map.with_index {|ite...
Symbol
• Symbol#to_proc
  •   [”matz”, “koichi”].map(&:upcase)
      #=> [“MATZ”, “KOICHI”]

• Treated more like Strings
 ...
IO

• Non blocking IO
• Limit input in read/get methods
• Oddness: doesn’t appear to be encoding
  aware
Misc.
• BasicObject at top of class hierarchy
• Class variables (@@woo) not inherited
• proc is now Proc.new instead of
  ...
The Ruby Ecosystem
• Rubygems
  •   0.9.5 is ruby 1.9 compatible

• Rake
• Rails
  •   ticket #1689 says Rails 2.1

• mong...
How do I get it?

• Wait till Christmas?
• http://svn.ruby-lang.org/repos/ruby/trunk
  •   Tiger users - upgrade your biso...
~fin~
•   http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9


•   http://www.atdot.net/yarv/rc2006_sasada_yarv_on_rails.pdf


• ...
Upcoming SlideShare
Loading in …5
×

Wild & Weird Ideas: An Overview of Ruby 1.9

12,403 views

Published on

A presentation I gave at the London Ruby User Group (LRUG) in December 2007 about the changes in the ruby programming language in the soon to be released 1.9 version.

Note that Ruby 1.9 was still in development at the time I wrote this talk, so it's possible the stuff I say in it is completely inaccurate with respect to any currently released version of Ruby 1.9.

Published in: Technology
24 Comments
11 Likes
Statistics
Notes
  • Presenter Notes:
    the sources I used to produce this talk<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Presenter Notes:
    the main site still points at ftp server, but the ruby1.9 snapshot not updated since sept<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Presenter Notes:
    Ruby isn’t a language that lives on it’s own
    what about everything that sits on top of 1.8 right now?

    1. gems -> 0.9.5 all about making the system 1.9 compatible
    movements to include it in core
    altho’ many deep conversations still happening about this
    2. rake -> mutterings about including it in core
    conversations about it’s upgradability (it’s a gem after all) if included in core
    but it appears that Jim Weirich can speak japanese, so I can’t work out the latest :(
    want to use it instead of make - but that means you need ruby to build ruby...
    3. Rails -> promising - active_support has a few unless RUBY_VERSION =~ /^1.9/ style code parts
    people claim 15% speed increase
    sure I’ve heard DHH say “we are not target for 1.9”
    could only find 2 tickets with ruby 1.9 in the summary.

    4. mongrel -> not so sure.
    based on fastthread, and YARV breaks that
    but there is mongrel 1.1.1 for jruby - jruby has no fastthread
    rumours that evented mongrel might work

    TBH very little info out there about 1.9 and apps -
    moriq (Kazuhiro Yoshida) last month last log<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Presenter Notes:
    1. BasicObject only contains send, object_id, respond_to, equal?
    it’s a complete blank slate.

    2. Class variables often cause confusion (for me)
    now they only belong to the single class they are defined on

    2. lambda vs proc.new
    appears to be to do with the semantics of return keyword
    lambdas can return safely, proc.new’s (and thus default block args) can’t

    3. this seems interesting, but I can’t find out anything more (no ri yet).
    Could just be syn for call, could be something more (cf lambda vs proc)

    4. could be a problem for meta programming / monkey patchers
    should use send!, but it doesn’t appear to work in the version I have<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Presenter Notes:
    1. Again, another thing big when added to java
    slightly less use now that threads are OS and blocking activities won’t block whole app
    loads of methods across the whole IO tree. make writing selecting rather than threaded servers easier.
    2. Can now provide limits to read/get methods of IO objects - so we don’t pull everything in one go
    good for memory consumption (or lack-thereof)
    3. Strangely - not apparently encoding aware
    open takes an encoding, but it doesn’t look like you can query an IO to ask what encoding it will give you. You have to ask the data it gives you.<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
12,403
On SlideShare
0
From Embeds
0
Number of Embeds
93
Actions
Shares
0
Downloads
351
Comments
24
Likes
11
Embeds 0
No embeds

No notes for slide

Wild & Weird Ideas: An Overview of Ruby 1.9

  1. Wild & Weird Ideas An overview of Ruby 1.9 LRUG 10th december 2007
  2. What is it? • The last odd-numbered release before Ruby 2.0 • “Wild &RubyConf Ideas” Weird - Matz, 2005 • More open development • http://www.rcrchive.net/
  3. When is it coming out? Christmas 2007
  4. The Biggest Change becomes
  5. The Biggest Change ... but let’s not complain ours isn’t much better!
  6. The Real Biggest Change YARV
  7. YARV 3 Things It Means To Us 1. New developer • not matz-bound 2. Better Performance • in places 3. Native threads • vs. green threads
  8. Other Changes Module#*_instance_methods Enumerable#first(n) Limit input Enumerable#cycle Method#name String#bytes Symbol#=== matches strings Removed Exception#to_str Array.try_convert Module#class_variable_defined? $SAFE and bound methods String no longer an Enumerable String#upto Enumerable#inject (#reduce) without a block Hash#to_s is equivalent to Hash#inspect Method#owner Non-blocking IO Enumerator#rewind String#partition, #rpartition Arity of blocks without arguments Struct#inspect Enumerable#group_by Process.daemon IO#lines String#lines Array#[m,n] = nil places nil in the array GC.stress, GC.stress= Range#include? Fiber: coroutines/micro-threads Array#nitems Hash#_compare_by_identity, #compare_by_identity? Object#=~ Enumerable methods called without a block Method#receiver Enumerable#count Mandatory arguments after optional arguments allowed String#encoding #to_path in File.<blah> Module#const_defined?, #const_get Dir.exist? New File and Dir operations ?c semantics Array#to_s is equivalent to Array#inspect Method used for splat arguments: #to_splat Regexp#=== matches symbols #class_variable_{set,get} Block argument to Array#index, Array#rindex String#ord #instance_exec Zero-length symbols allowed IO.try_convert Semantics for Hash#each and Hash#each_pair Deprecated: StringScanner Proc#yield Deprecated: Kernel#getc New literal hash syntax Block local variables Binding#eval Range#min, Range#max send doesn't always call private methods anymore Deprecated: Object#type Numeric#upto, #downto, #times, #step BasicObject Process.exec IO#bytes Enumerable#reduce proc is now a synonym of Proc.new Integer#pred Deprecated: Kernel.to_a Multiple splats allowed Kernel#require Enumerator#with_index StringIO#readpartial Dir.[], Dir.glob Enumerable#each_with_index Passing blocks to #[] Module#attr is an alias of attr_reader News semantics for block arguments String.try_convert Symbols: restriction on literal symbols Regexp.try_convert Deprecated: File.exists? Deprecated: Hash#index Method#hash, Proc#hash IO#ungetc, StringIO#ungetc IO#getc Block arguments are always local Deprecated: Symbol#to_int Extra subclassing check when binding UnboundMethods Equality of exceptions Deprecated: Removed Array and Hash #indices, #indexes Enumerable#find_index Symbol#to_proc Integer#odd?, #even? .() and calling Procs without #call/#[] Deprecated:VERSION and friends Symbol#intern Timezone information preserved on Marshal.dump/load Block arguments Kernel#define_singleton_method Process.setrlimit Hash#select Kernel#open Array#pop, Array#shift Array#product IO#initialize now accepts an IO argument String#force_encoding Symbol methods similar to those in String Kernel#singleton_methods, Kernel#methods Regexp#match, String#match Math#log and Math#log2 Array#combination String#unpack with a block defined? and local variables Newlines allowed before ternary colon String#hash Numeric#scalar?, Complex#scalar? quot;One-char-widequot; semantics for String#[] and String#[]= Enumerator#each #module_exec String#each_char Enumerable#min_by, #max_by Numeric#fdiv SystemStackError Enumerable#drop Range#cover? Arguments to #[] Integer(nil) raises TypeError Enumerable#minmax, #minmax_by Symbol#encoding Deprecated: ENV.index Proc#lambda? String#start_with?, #end_with? String#clear Numeric#div __method__ and __callee__ Object#tap Hash.try_convert Array#permutation Enumerable#zip New format in Time#to_s String has encoding-awareness Enumerable#take NameError Class variables are not inherited IO & StringIO #getbyte, #readbyte Class of singleton classes Kernel#instance_variable_defined? New syntax for lambdas printf-style formatted strings (%)
  9. Other Changes a lot
  10. New Syntax
  11. irb> c = -> (a, b) {a.times{puts b}} => #<Proc:0x48adf0@(irb):34 (lambda)> irb> c.call(2, 'hello') hello hello => 2
  12. irb> c = ->(a, b = ‘muz’) do irb* a.times{puts b} irb> end => #<Proc:0x52f17a@(irb):50 (lambda)> irb> c.call(1) muz => 1
  13. irb> c = ->(a, b, &c) do irb* a.times{c.call(b)} irb> end => #<Proc:0x65cd68@(irb):36 (lambda)> irb> c.call(2, 'hello'){|b| puts b*2} hellohello hellohello => 2
  14. irb> def lolmatz(n1, v=‘SPESIFY’, n2) irb> “IN YR #{n1} #{v}IN YR #{n2}” irb> end => nil irb> lolmatz(‘RUBY’,’LANGUJ’) => “IN YR RUBY SPESIFYIN YR LANGUJ”
  15. irb> c = -> (a, b) {a.times{puts b}} => #<Proc:0x48adf0@(irb):34 (lambda)> irb> c.(2, 'hello') hello hello => 2
  16. irb> num = [1,2,3] irb> bers = [4,5,6] irb> numbers = [*num, *bers] => [1,2,3,4,5,6]
  17. Changes to the Standard Library
  18. String • Encoding aware • methods are char, not byte, based now • open(‘blah.txt’, ‘r:utf-8’) • # -*- coding: utf-8 -*- • Bye Bye: $KCODE and jcode • No longer an Enumerable
  19. Enumerable • Enumerable::Enumerator part of core • Enumerable methods without a block • [1,2,3].map.with_index {|item, idx| ...} • #inject without block • [1,2,3].inject(:+) #=> 6
  20. Symbol • Symbol#to_proc • [”matz”, “koichi”].map(&:upcase) #=> [“MATZ”, “KOICHI”] • Treated more like Strings • #encoding, #empty?, #upcase, #[], #match, etc... • #===
  21. IO • Non blocking IO • Limit input in read/get methods • Oddness: doesn’t appear to be encoding aware
  22. Misc. • BasicObject at top of class hierarchy • Class variables (@@woo) not inherited • proc is now Proc.new instead of lambda • Proc#yield a method for yield keyword • send shouldn’t invoke private methods
  23. The Ruby Ecosystem • Rubygems • 0.9.5 is ruby 1.9 compatible • Rake • Rails • ticket #1689 says Rails 2.1 • mongrel • http://www.moriq.com/ruby/1.9/log/
  24. How do I get it? • Wait till Christmas? • http://svn.ruby-lang.org/repos/ruby/trunk • Tiger users - upgrade your bison • Windows binaries available
  25. ~fin~
  26. • http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9 • http://www.atdot.net/yarv/rc2006_sasada_yarv_on_rails.pdf • http://learnruby.com/ruby-1.9.html • http://www.rubyinside.com/so-heres-the-new-ruby-logo-639.html • http://www.ruby-lang.org/en/community/ruby-core/ • http://www.rubyist.net/~matz/slides/ • http://blog.grayproductions.net/categories/the_ruby_vm_interview

×