Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What's new in Ruby 2.0


Published on

In this presentation, I walk the audience through a bunch of changes in Ruby 2.0.

Published in: Technology
  • That's an interesting and beautiful presentation. Can you share the background (especially the light/yellowish one)? Thanks
    Are you sure you want to  Yes  No
    Your message goes here

What's new in Ruby 2.0

  1. 1. Ruby 2.0 What’s  new?
  2. 2. r ions@ gee_for Interne t Solut About me by I <3 Ru #rub yOnBeer
  3. 3. History Install Deep Changes Big LittleChanges Changes Eco System
  4. 4. History
  5. 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 2005I  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. 6. Ruby’s History Rails  arrives  on  the   scene.  Arguably  the   start  of  Ruby’s  rise. Aug Dec 2003 2007 Dec 13 2.0 2005nguage  starts  gaining   Feb 24 Start  of  Xmas  Tradi.on the  big   Language  hits  rious  trac.on .me. 2013 1.8 1.9
  7. 7. Install
  8. 8. The one tru e way t rue way The oneRVM RBENV✦Update  RVM ✦Update  rbenv✦rvm install ruby-2.0.0 ✦rbenv install 2.0.0-p0
  9. 9. Deep Changes
  10. 10. X X XBItmap Garbage Collection X X X
  11. 11. 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:
  12. 12. 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:
  13. 13. X X X BackwardCompatible With 1.9 X X X
  14. 14. X X Xrequire() speed improvements X X X
  15. 15. Big Changes
  16. 16. X X X KeywordArguments X X X
  17. 17. Big Changes KeywordArguments def foo(foo: ‘bar’, baz: ‘qux’, **rest) # Do something end foo(baz: ‘noqux’, foo: ‘frob’)
  18. 18. X X XModulePrepend X X X
  19. 19. Big ChangesModulePrepend module IncludableModule def something; end end class MyClass prepend IncludableModule end
  20. 20. X X X LazyEnumerators X X X
  21. 21. Big Changes LazyEnumerators to_infinity = (0..Float::Infinity)beyond = do |n| num % 42 == 0end100.times do { |n| puts }
  22. 22. X X XTracepoint X X X
  23. 23. Big Changes Trace PointOO  alterna*ve  to  set_trace_functrace = do |t| puts "Alert: Exception raised!"endtrace.enable
  24. 24. X X XRefinements X X X
  25. 25. Big ChangesRefinements *Localised  and  contained  monkey  patchingModule MyString refine String do def palindrome? self == self.reverse end endendusing MyString # Monkey patch now active for context
  26. 26. little Changes
  27. 27. Little Changes LiteralSymbol listssym_list = %i{eeny meeny miny moe}# => [:eeny, :meeny, :miny, :moe]
  28. 28. Little Changes Binary Searchhaystack = (1..99999999)haystack.bsearch do |needle| needle == 12345end# => 12345
  29. 29. Little Changes UTF-8On by Default#!/usr/bin/env ruby1.9#encoding: utf-8puts “✖ ✹ ✚ ✭”#!/usr/bin/env ruby-2.0puts “✖ ✹ ✚ ✭”
  30. 30. Little Changes __Dir__ keywordSimilar  in  func*onality  to  __FILE__Shows  absolute  path  to  file’s  directoryNo  more  clunky  File.dirname(__FILE__)
  31. 31. Little Changes .to_hFollows  conven*on  started  by  .to_s,  to_i,  to_a,  etcSuper  useful  for  conver*ng  Structs
  32. 32. Little Changes Grab BagCGI  is  now  HTML5  compa*blenet/hLp  supports  Server  Name  Indica*on  (SNI)Zlib  runs  outside  of  the  Global  Interpreter  LockUnused  variables  can  be  prepended  with  _  to  avoid  warnings
  33. 33. Ecosystem
  34. 34. Ecosystem RubyGems 2.0Start  of  support  for  stdlib  gemsNo  more  out  of  place  requires!  MOAR  BUNDLAR!Searching  is  remote  by  defaultMetadata  through  Gem::Specifica*on#metadataSimplified  --document/--no-documentNo  more  --no-rdoc --no-ri mantra
  35. 35. Ecosystem Bundler 1.3(.1)Supports  Ruby  2.0Supports  Rubygems  2.0Supports  Rails  4.0install and update up  to  150x  fasterSupport  for  signed  gems!
  36. 36. EcoSystem Rails 4.0 betaRuby  2.0  is  the  official  preferred  ruby  versionBeta  released  1  day  a_er  Ruby  2.0gem install rails --version 4.0.0.beta1 --no-documentgem ‘rails’, ‘4.0.0-beta1’
  37. 37. Now what
  38. 38. Thanks AnyQuestions? @gee_forr GEE.FORR@GMAIL.COM