• Save
What's new in Ruby 2.0
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

What's new in Ruby 2.0

  • 1,159 views
Uploaded on

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

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

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

Views

Total Views
1,159
On Slideshare
1,159
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
1
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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 LittleChanges Changes Eco System
  • 4. History
  • 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. 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. Install
  • 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. Deep Changes
  • 10. X X XBItmap Garbage Collection X X X
  • 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: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
  • 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: http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
  • 13. X X X BackwardCompatible With 1.9 X X X
  • 14. X X Xrequire() speed improvements X X X
  • 15. Big Changes
  • 16. X X X KeywordArguments X X X
  • 17. Big Changes KeywordArguments def foo(foo: ‘bar’, baz: ‘qux’, **rest) # Do something end foo(baz: ‘noqux’, foo: ‘frob’)
  • 18. X X XModulePrepend X X X
  • 19. Big ChangesModulePrepend module IncludableModule def something; end end class MyClass prepend IncludableModule end
  • 20. X X X LazyEnumerators X X X
  • 21. Big Changes LazyEnumerators to_infinity = (0..Float::Infinity)beyond = to_infinity.lazy.select do |n| num % 42 == 0end100.times do { |n| puts beyond.next }
  • 22. X X XTracepoint X X X
  • 23. Big Changes Trace PointOO  alterna*ve  to  set_trace_functrace = TracePoint.new(:raise) do |t| puts "Alert: Exception raised!"endtrace.enable
  • 24. X X XRefinements X X X
  • 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. little Changes
  • 27. Little Changes LiteralSymbol listssym_list = %i{eeny meeny miny moe}# => [:eeny, :meeny, :miny, :moe]
  • 28. Little Changes Binary Searchhaystack = (1..99999999)haystack.bsearch do |needle| needle == 12345end# => 12345
  • 29. Little Changes UTF-8On by Default#!/usr/bin/env ruby1.9#encoding: utf-8puts “✖ ✹ ✚ ✭”#!/usr/bin/env ruby-2.0puts “✖ ✹ ✚ ✭”
  • 30. Little Changes __Dir__ keywordSimilar  in  func*onality  to  __FILE__Shows  absolute  path  to  file’s  directoryNo  more  clunky  File.dirname(__FILE__)
  • 31. Little Changes .to_hFollows  conven*on  started  by  .to_s,  to_i,  to_a,  etcSuper  useful  for  conver*ng  Structs
  • 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. Ecosystem
  • 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. 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. 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. Now what
  • 38. Thanks AnyQuestions? @gee_forr GEE.FORR@GMAIL.COM