SlideShare a Scribd company logo
Ruby 2.0
  What’s	
  new?
r                          ions
@ gee_for            Interne
                             t Solut




              About me


         by
 I <3 Ru              #rub yOnBeer
History             Install



            Deep
          Changes

  Big                Little
Changes             Changes


            Eco
          System
History
Ruby’s History

                                  0.95                                                                                      Rails	
  arrives	
  on	
  the	
  
                                                                                                                            scene.	
  Arguably	
  the	
  
                            First	
  public	
  release                                                                      start	
  of	
  Ruby’s	
  rise.



          Feb 24                                         Dec 25                          Aug
           1993                                           1996                    1.2    1999   1.6
                                                                                                              Aug
                                                                                                              2003
                                                                                                                                                                Dec
                                                                                                                                                                2007


                                         Dec 21                                   Dec            Sep                                Dec 13
                                          1995                                    1998   1.4    2000                                 2005



I	
  want	
  a	
  language	
  more	
  
powerful	
  than	
  Perl	
  and	
               Start	
  of	
  Xmas	
  Tradi.on                    Language	
  starts	
  gaining	
                 Language	
  hits	
  the	
  big	
  
more	
  OO	
  than	
  Python                                                                       serious	
  trac.on                              .me.



                                                          1.0                                                 1.8                                               1.9
Ruby’s History

                       Rails	
  arrives	
  on	
  the	
  
                       scene.	
  Arguably	
  the	
  
                       start	
  of	
  Ruby’s	
  rise.




        Aug                                                Dec
        2003                                               2007


                               Dec 13
                                                                              2.0
                                2005




nguage	
  starts	
  gaining	
  
                                                                             Feb 24
                            Start	
  of	
  Xmas	
  Tradi.on the	
  big	
  
                                            Language	
  hits	
  
rious	
  trac.on                            .me.
                                                                              2013
        1.8                                                1.9
Install
The one tru
                                 e way
                             t rue way
                     The one


RVM                              RBENV
✦Update	
  RVM                   ✦Update	
  rbenv

✦rvm install ruby-2.0.0          ✦rbenv install 2.0.0-p0
Deep Changes
X
         X   X


BItmap Garbage
   Collection

     X   X   X
What's new in Ruby 2.0
1.9 GC
                                                 Heap based M&S
                                                 Ruby	
  structures	
  are	
  divided	
  in	
  2	
  	
  
                                                 halves,	
  data	
  and	
  flags.	
  Each	
  
                                                 structure	
  has	
  its	
  own	
  flag.	
  Mark	
  
                                                 phase	
  trawls	
  through	
  heap	
  and	
  
                                                 updates	
  FL_MARK	
  flag	
  in	
  every	
  
                                                 object




         RString diagram from: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
2.0 GC
                                              Bitmap marking
                                              All	
  mark	
  flags	
  for	
  heap	
  move	
  to	
  
                                              single	
  dedicated	
  data	
  structure.	
  
                                              1	
  for	
  In	
  Use,	
  0	
  for	
  Collectable.

                                              Flag	
  not	
  wriMen	
  to	
  data	
  
                                              structure,	
  much	
  more	
  friendly	
  
                                              to	
  copy-­‐on-­‐write




         Heap diagram from: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
X
         X   X


   Backward
Compatible With
      1.9
     X   X   X
X
         X   X


require() speed
 improvements

     X   X   X
Big Changes
X
      X   X


 Keyword
Arguments

  X   X   X
Big Changes



 Keyword
Arguments
     def foo(foo: ‘bar’, baz: ‘qux’, **rest)
       # Do something
     end
     foo(baz: ‘noqux’, foo: ‘frob’)
X
     X   X


Module
Prepend

 X   X   X
Big Changes

Module
Prepend
    module IncludableModule
      def something; end
    end
    class MyClass
      prepend IncludableModule
    end
X
       X   X


    Lazy
Enumerators

   X   X   X
Big Changes

   Lazy
Enumerators
               to_infinity = (0..Float::Infinity)
beyond = to_infinity.lazy.select do |n|
  num % 42 == 0
end

100.times do { |n| puts beyond.next }
X
      X   X




Tracepoint

  X   X   X
Big Changes

         Trace
         Point
OO	
  alterna*ve	
  to	
  set_trace_func
trace = TracePoint.new(:raise) do |t|
  puts "Alert: Exception raised!"
end

trace.enable
X
       X   X




Refinements

   X   X   X
Big Changes

Refinements
     *
Localised	
  and	
  contained	
  monkey	
  patching
Module MyString
  refine String do
    def palindrome?
      self == self.reverse
    end
  end
end

using MyString # Monkey patch now active for context
little Changes
Little Changes

  Literal
Symbol lists
sym_list = %i{eeny meeny miny moe}

# => [:eeny, :meeny, :miny, :moe]
Little Changes

      Binary
      Search
haystack = (1..99999999)


haystack.bsearch do |needle|
    needle == 12345
end

# => 12345
Little Changes

    UTF-8
On by Default
#!/usr/bin/env ruby1.9
#encoding: utf-8

puts “✖ ✹ ✚ ✭”

#!/usr/bin/env ruby-2.0

puts “✖ ✹ ✚ ✭”
Little Changes


           __Dir__
          keyword
Similar	
  in	
  func*onality	
  to	
  __FILE__
Shows	
  absolute	
  path	
  to	
  file’s	
  directory
No	
  more	
  clunky	
  File.dirname(__FILE__)
Little Changes


                   .to_h
Follows	
  conven*on	
  started	
  by	
  .to_s,	
  to_i,	
  to_a,	
  etc
Super	
  useful	
  for	
  conver*ng	
  Structs
Little Changes


                   Grab
                   Bag
CGI	
  is	
  now	
  HTML5	
  compa*ble
net/hLp	
  supports	
  Server	
  Name	
  Indica*on	
  (SNI)

Zlib	
  runs	
  outside	
  of	
  the	
  Global	
  Interpreter	
  Lock
Unused	
  variables	
  can	
  be	
  prepended	
  with	
  _	
  to	
  avoid	
  warnings
Ecosystem
Ecosystem


         RubyGems
            2.0
Start	
  of	
  support	
  for	
  stdlib	
  gems
No	
  more	
  out	
  of	
  place	
  requires!	
  MOAR	
  BUNDLAR!

Searching	
  is	
  remote	
  by	
  default
Metadata	
  through	
  Gem::Specifica*on#metadata
Simplified	
  --document/--no-document
No	
  more	
  --no-rdoc --no-ri mantra
Ecosystem


        Bundler
         1.3(.1)
Supports	
  Ruby	
  2.0
Supports	
  Rubygems	
  2.0

Supports	
  Rails	
  4.0
install and update up	
  to	
  150x	
  faster
Support	
  for	
  signed	
  gems!
EcoSystem


               Rails
             4.0 beta
Ruby	
  2.0	
  is	
  the	
  official	
  preferred	
  ruby	
  version
Beta	
  released	
  1	
  day	
  a_er	
  Ruby	
  2.0
gem install rails --version 4.0.0.beta1 --no-document
gem ‘rails’, ‘4.0.0-beta1’
Now what
Thanks


   Any
Questions?

             @gee_forr
             GEE.FORR@GMAIL.COM

More Related Content

PPTX
A house powered by wind and wave energy
PPT
Plantadetarrega defini
PPT
Visita depuradura calaix histories
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
PDF
2024 State of Marketing Report – by Hubspot
A house powered by wind and wave energy
Plantadetarrega defini
Visita depuradura calaix histories
2024 Trend Updates: What Really Works In SEO & Content Marketing
Storytelling For The Web: Integrate Storytelling in your Design Process
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
2024 State of Marketing Report – by Hubspot

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation theory and applications.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Cloud computing and distributed systems.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
“AI and Expert System Decision Support & Business Intelligence Systems”
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation theory and applications.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectroscopy.pptx food analysis technology
Cloud computing and distributed systems.
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
Ad
Ad

What's new in Ruby 2.0

  • 1. Ruby 2.0 What’s  new?
  • 2. r ions @ gee_for Interne t Solut About me by I <3 Ru #rub yOnBeer
  • 3. History Install Deep Changes Big Little Changes Changes Eco System
  • 5. Ruby’s History 0.95 Rails  arrives  on  the   scene.  Arguably  the   First  public  release start  of  Ruby’s  rise. Feb 24 Dec 25 Aug 1993 1996 1.2 1999 1.6 Aug 2003 Dec 2007 Dec 21 Dec Sep Dec 13 1995 1998 1.4 2000 2005 I  want  a  language  more   powerful  than  Perl  and   Start  of  Xmas  Tradi.on Language  starts  gaining   Language  hits  the  big   more  OO  than  Python serious  trac.on .me. 1.0 1.8 1.9
  • 6. Ruby’s History Rails  arrives  on  the   scene.  Arguably  the   start  of  Ruby’s  rise. Aug Dec 2003 2007 Dec 13 2.0 2005 nguage  starts  gaining   Feb 24 Start  of  Xmas  Tradi.on the  big   Language  hits   rious  trac.on .me. 2013 1.8 1.9
  • 8. The one tru e way t rue way The one RVM RBENV ✦Update  RVM ✦Update  rbenv ✦rvm install ruby-2.0.0 ✦rbenv install 2.0.0-p0
  • 10. X X X BItmap Garbage Collection X X X
  • 12. 1.9 GC Heap based M&S Ruby  structures  are  divided  in  2     halves,  data  and  flags.  Each   structure  has  its  own  flag.  Mark   phase  trawls  through  heap  and   updates  FL_MARK  flag  in  every   object RString diagram from: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
  • 13. 2.0 GC Bitmap marking All  mark  flags  for  heap  move  to   single  dedicated  data  structure.   1  for  In  Use,  0  for  Collectable. Flag  not  wriMen  to  data   structure,  much  more  friendly   to  copy-­‐on-­‐write Heap diagram from: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
  • 14. X X X Backward Compatible With 1.9 X X X
  • 15. X X X require() speed improvements X X X
  • 17. X X X Keyword Arguments X X X
  • 18. Big Changes Keyword Arguments def foo(foo: ‘bar’, baz: ‘qux’, **rest) # Do something end foo(baz: ‘noqux’, foo: ‘frob’)
  • 19. X X X Module Prepend X X X
  • 20. Big Changes Module Prepend module IncludableModule def something; end end class MyClass prepend IncludableModule end
  • 21. X X X Lazy Enumerators X X X
  • 22. Big Changes Lazy Enumerators to_infinity = (0..Float::Infinity) beyond = to_infinity.lazy.select do |n| num % 42 == 0 end 100.times do { |n| puts beyond.next }
  • 23. X X X Tracepoint X X X
  • 24. Big Changes Trace Point OO  alterna*ve  to  set_trace_func trace = TracePoint.new(:raise) do |t| puts "Alert: Exception raised!" end trace.enable
  • 25. X X X Refinements X X X
  • 26. Big Changes Refinements * Localised  and  contained  monkey  patching Module MyString refine String do def palindrome? self == self.reverse end end end using MyString # Monkey patch now active for context
  • 28. Little Changes Literal Symbol lists sym_list = %i{eeny meeny miny moe} # => [:eeny, :meeny, :miny, :moe]
  • 29. Little Changes Binary Search haystack = (1..99999999) haystack.bsearch do |needle| needle == 12345 end # => 12345
  • 30. Little Changes UTF-8 On by Default #!/usr/bin/env ruby1.9 #encoding: utf-8 puts “✖ ✹ ✚ ✭” #!/usr/bin/env ruby-2.0 puts “✖ ✹ ✚ ✭”
  • 31. Little Changes __Dir__ keyword Similar  in  func*onality  to  __FILE__ Shows  absolute  path  to  file’s  directory No  more  clunky  File.dirname(__FILE__)
  • 32. Little Changes .to_h Follows  conven*on  started  by  .to_s,  to_i,  to_a,  etc Super  useful  for  conver*ng  Structs
  • 33. Little Changes Grab Bag CGI  is  now  HTML5  compa*ble net/hLp  supports  Server  Name  Indica*on  (SNI) Zlib  runs  outside  of  the  Global  Interpreter  Lock Unused  variables  can  be  prepended  with  _  to  avoid  warnings
  • 35. Ecosystem RubyGems 2.0 Start  of  support  for  stdlib  gems No  more  out  of  place  requires!  MOAR  BUNDLAR! Searching  is  remote  by  default Metadata  through  Gem::Specifica*on#metadata Simplified  --document/--no-document No  more  --no-rdoc --no-ri mantra
  • 36. Ecosystem Bundler 1.3(.1) Supports  Ruby  2.0 Supports  Rubygems  2.0 Supports  Rails  4.0 install and update up  to  150x  faster Support  for  signed  gems!
  • 37. EcoSystem Rails 4.0 beta Ruby  2.0  is  the  official  preferred  ruby  version Beta  released  1  day  a_er  Ruby  2.0 gem install rails --version 4.0.0.beta1 --no-document gem ‘rails’, ‘4.0.0-beta1’
  • 39. Thanks Any Questions? @gee_forr GEE.FORR@GMAIL.COM