SlideShare une entreprise Scribd logo
1  sur  91
Télécharger pour lire hors ligne
O que tem de novo no

Ruby 2?
               Fabio Akita
              @akitaonrails
          codeminer42.com
Ruby 0.95   Dez 1995

Ruby 1.8    Ago 2003

Rails 0.8   Dez 2005

Ruby 1.9    Dez 2007
Ruby 0.95   Dez 1995

Ruby 1.8    Ago 2003

Rails 0.8   Dez 2005

Ruby 1.9    Dez 2007
Ruby 0.95   Dez 1995

Ruby 1.8    Ago 2003

Rails 0.8   Dez 2005

Ruby 1.9    Dez 2007
Ruby 0.95   Dez 1995

Ruby 1.8    Ago 2003

Rails 0.8   Dez 2005

Ruby 1.9    Dez 2007
Ruby 2.0
  24 de Fevereiro de 2013
Compatível com 1.9
Literal Symbol List
> %q[hello world]
=> "hello world"

> %i[hello world]
=> [:hello, :world]
Keyword Arguments
def foo(options = {})
  param1 = options[:param1]
  param2 = options[:param2]
  return [param1, param2]
end

> foo param1: "Hello", param2: "World"
=> ["Hello", "World"]
def foo(param1: nil, param2: nil)
  return [param1, param2]
end

> foo param1: "Hello", param2: "World"
=> ["Hello", "World"]
Module Prepend
> [1,2,3].to_s
=> "[1, 2, 3]"
module Foo
  def self.included(base)
    base.class_eval do
      alias_method :original_to_s, :to_s

      def to_s
        original_to_s + ", Foo"
      end
    end
  end
end

class Array
  include Foo
end
> [1,2,3].to_s
=> "[1, 2, 3], Foo"

> Array.ancestors
=> [Array, Foo, Enumerable, Object, Kernel,
BasicObject]
module Foo
  def to_s
    super + ", Foo"
  end
end

class Array
  prepend Foo
end
> [1,2,3].to_s
=> "[1, 2, 3], Foo"

> Array.ancestors
=> [Foo, Array, Enumerable, Object, Kernel,
BasicObject]
Lazy Enumerators
> a = (0..3).map { |i| i }
=> [0, 1, 2, 3]
> a = (0..3).lazy.map { |i| i }
=> #<Enumerator::Lazy: #<Enumerator::Lazy: 0..3>:map>

> a.next
=> 0
> a.next
=> 1
> a.next
=> 2
> a.next
=> 3
> a = (0..Float::INFINITY).lazy.map { |i| i }
=> #<Enumerator::Lazy: #<Enumerator::Lazy:
0..Infinity>:map>

> a.next
=> 0
> a.next
=> 1
> a.next
=> 2
> a.next
=> 3
Refinements
module Foo
  def hello
    "Hello, #{to_s}"
  end
end

class Array
  include Foo
end

> [1,2,3].hello
=> "Hello, [1, 2, 3]"
module Foo
  refine Array do
    def hello
      "Hello, #{to_s}"
    end
  end
end

using Foo

> [1,2,3].hello
=> "Hello, [1, 2, 3]"
module Foo               def bah
  refine Array do          [1,2,3].hello
    def hello            end
      "Hello, #{to_s}"
    end                  > bah.hello
  end                    NoMethodError: undefined
end                      method `hello' for
                         "Hello, [1, 2,
using Foo                3]":String

> [1,2,3].hello
=> "Hello, [1, 2, 3]"
http://rvm.io
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
http://gembundler.com/
Browser




NGINX


Worker




 Linux
Browser




NGINX


Worker




 Linux
Browser




NGINX


Worker




 Ruby


 Linux
Browser




NGINX


Worker


 Rails

 Ruby


 Linux
Browser




NGINX


Worker


 Rails

 Ruby


 Linux
Browser   Browser           Browser   Browser




                    NGINX


Worker    Worker            Worker    Worker


 Rails     Rails             Rails      Rails

Ruby       Ruby              Ruby      Ruby


                    Linux
Browser   Browser           Browser   Browser




                    NGINX


Worker    Worker            Worker    Worker


 Rails     Rails             Rails      Rails

Ruby       Ruby              Ruby      Ruby


                    Linux
M&S
Mark & Sweep GC
struct RBasic {
    VALUE flags;   RString
                    flags

    VALUE klass;    klass

};
RString   RString   RString
 flags     flags     flags

 klass     klass     klass
RString   RString   RString
 flags     flags     flags

 klass     klass     klass




          fork()
RString   RString   RString
 flags     flags     flags

 klass     klass     klass




          fork()
RString    RString     RString
 flags       flags      flags

 klass       klass      klass




          GC.start()



RString    RString     RString
 flags       flags      flags

 klass       klass      klass
OOBW
 Out of Band Work
Lazy
Lazy Sweep GC - Ruby 1.9.3
“CoW”
 Copy on Write
RString   RString   RString
 flags     flags     flags

 klass     klass     klass
RString   RString   RString
 flags     flags     flags

 klass     klass     klass
RString   RString   RString
 flags     flags     flags

 klass     klass     klass
RString   RString   RString
 flags     flags     flags

 klass     klass     klass
fork()
GC.start
Bitmap
Bitmap Marking GC - Ruby 2.0
9   00001001


8   00001000


7   00000111
9   00001001


8   00001000


7   00000111
9   00001001


8   00001000


7   00000111
00000001   2^0   1     User


00000010   2^1   2   Moderator


00000100   2^2   4 Administrator
00000001   2^0   1     User


00000010   2^1   2   Moderator


00000100   2^2   4 Administrator
00000001   2^0   1     User


00000010   2^1   2   Moderator


00000100   2^2   4 Administrator
1   1   1   0   0   0   0   0   0   0   0
1   1   1   0   0   0   0   0   0   0   0




                                            fork()
fork()
fork()
Browser   Browser           Browser   Browser




                    NGINX


Worker    Worker            Worker    Worker


 Rails     Rails             Rails      Rails

Ruby       Ruby              Ruby      Ruby


                    Linux
Browser
     Browser
          Browser
               Browser
                    Browser
                         Browser
                              Browser
                                   Browser
                                        Browser
                                             Browser




                             NGINX


  Worker Worker
      Worker Worker
                 Worker
                     Worker
                         Worker
                             Worker
                                 Worker
                                     Worker


   Rails Rails Rails Rails Rails Rails Rails Rails Rails Rails

   RubyRuby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby


                             Linux
Browser
     Browser
          Browser
               Browser
                    Browser
                         Browser
                              Browser
                                   Browser
                                        Browser
                                             Browser




                             NGINX


  Worker Worker
      Worker Worker
                 Worker
                     Worker
                         Worker
                             Worker
                                 Worker
                                     Worker


   Rails Rails Rails Rails Rails Rails Rails Rails Rails Rails

   RubyRuby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby


                             Linux
Rails 3.2.12+


  Rails 4.0
Thanks!
 @akitaonrails

Contenu connexe

Tendances

20140419 oedo rubykaigi04
20140419 oedo rubykaigi0420140419 oedo rubykaigi04
20140419 oedo rubykaigi04
Hiroshi SHIBATA
 
20140425 ruby conftaiwan2014
20140425 ruby conftaiwan201420140425 ruby conftaiwan2014
20140425 ruby conftaiwan2014
Hiroshi SHIBATA
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02
Hiroshi SHIBATA
 

Tendances (20)

20140419 oedo rubykaigi04
20140419 oedo rubykaigi0420140419 oedo rubykaigi04
20140419 oedo rubykaigi04
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Roadmap for RubyGems 4 and Bundler 3
Roadmap for RubyGems 4 and Bundler 3Roadmap for RubyGems 4 and Bundler 3
Roadmap for RubyGems 4 and Bundler 3
 
20140425 ruby conftaiwan2014
20140425 ruby conftaiwan201420140425 ruby conftaiwan2014
20140425 ruby conftaiwan2014
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
 
The Future of library dependency management of Ruby
 The Future of library dependency management of Ruby The Future of library dependency management of Ruby
The Future of library dependency management of Ruby
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 

Similaire à O que tem de novo no Ruby 2.0?

One RubyStack to Rule them All
One RubyStack to Rule them AllOne RubyStack to Rule them All
One RubyStack to Rule them All
elliando dias
 
Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0
ArrrrCamp
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
elliando dias
 
Ruby and Rails short motivation
Ruby and Rails short motivationRuby and Rails short motivation
Ruby and Rails short motivation
jistr
 

Similaire à O que tem de novo no Ruby 2.0? (20)

Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
 
One RubyStack to Rule them All
One RubyStack to Rule them AllOne RubyStack to Rule them All
One RubyStack to Rule them All
 
Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Úvod do Ruby on Rails
Úvod do Ruby on RailsÚvod do Ruby on Rails
Úvod do Ruby on Rails
 
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
 
Ruby and Rails short motivation
Ruby and Rails short motivationRuby and Rails short motivation
Ruby and Rails short motivation
 
CRuby Committers Who's Who in 2013
CRuby Committers Who's Who in 2013CRuby Committers Who's Who in 2013
CRuby Committers Who's Who in 2013
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - Deployment
 
Deployment de Rails
Deployment de RailsDeployment de Rails
Deployment de Rails
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystem
 
Lambda Layers 로 람다함수 다이어트 하기 :: 이경우 - AWS Community Day 2019
Lambda Layers 로 람다함수 다이어트 하기 :: 이경우 - AWS Community Day 2019 Lambda Layers 로 람다함수 다이어트 하기 :: 이경우 - AWS Community Day 2019
Lambda Layers 로 람다함수 다이어트 하기 :: 이경우 - AWS Community Day 2019
 
Ruby on Docker
Ruby on DockerRuby on Docker
Ruby on Docker
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
Ruby Beyond Rails
Ruby Beyond RailsRuby Beyond Rails
Ruby Beyond Rails
 
Bhavesh ro r
Bhavesh ro rBhavesh ro r
Bhavesh ro r
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 

Plus de Fabio Akita

Plus de Fabio Akita (20)

Devconf 2019 - São Carlos
Devconf 2019 - São CarlosDevconf 2019 - São Carlos
Devconf 2019 - São Carlos
 
Meetup Nerdzão - English Talk about Languages
Meetup Nerdzão  - English Talk about LanguagesMeetup Nerdzão  - English Talk about Languages
Meetup Nerdzão - English Talk about Languages
 
Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018
Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018
Desmistificando Blockchains p/ Developers - Criciuma Dev Conf 2018
 
Desmistificando Blockchains - 20o Encontro Locaweb SP
Desmistificando Blockchains - 20o Encontro Locaweb SPDesmistificando Blockchains - 20o Encontro Locaweb SP
Desmistificando Blockchains - 20o Encontro Locaweb SP
 
Desmistificando Blockchains - Insiter Goiania
Desmistificando Blockchains - Insiter GoianiaDesmistificando Blockchains - Insiter Goiania
Desmistificando Blockchains - Insiter Goiania
 
Blockchain em 7 minutos - 7Masters
Blockchain em 7 minutos - 7MastersBlockchain em 7 minutos - 7Masters
Blockchain em 7 minutos - 7Masters
 
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
Elixir  -Tolerância a Falhas para Adultos - GDG CampinasElixir  -Tolerância a Falhas para Adultos - GDG Campinas
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
 
Desmistificando Mitos de Tech Startups - Intercon 2017
Desmistificando Mitos de Tech Startups - Intercon 2017Desmistificando Mitos de Tech Startups - Intercon 2017
Desmistificando Mitos de Tech Startups - Intercon 2017
 
30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby
 
Uma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TIUma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TI
 
THE CONF - Opening Keynote
THE CONF - Opening KeynoteTHE CONF - Opening Keynote
THE CONF - Opening Keynote
 
A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017
 
Desmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - APDesmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - AP
 
A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017
 
A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017
 
A Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech DayA Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech Day
 
A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016
 
Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016
 
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização PrematuraConexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
 
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All EvilThe Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

O que tem de novo no Ruby 2.0?

  • 1. O que tem de novo no Ruby 2? Fabio Akita @akitaonrails codeminer42.com
  • 2.
  • 3.
  • 4. Ruby 0.95 Dez 1995 Ruby 1.8 Ago 2003 Rails 0.8 Dez 2005 Ruby 1.9 Dez 2007
  • 5. Ruby 0.95 Dez 1995 Ruby 1.8 Ago 2003 Rails 0.8 Dez 2005 Ruby 1.9 Dez 2007
  • 6. Ruby 0.95 Dez 1995 Ruby 1.8 Ago 2003 Rails 0.8 Dez 2005 Ruby 1.9 Dez 2007
  • 7. Ruby 0.95 Dez 1995 Ruby 1.8 Ago 2003 Rails 0.8 Dez 2005 Ruby 1.9 Dez 2007
  • 8. Ruby 2.0 24 de Fevereiro de 2013
  • 11. > %q[hello world] => "hello world" > %i[hello world] => [:hello, :world]
  • 13. def foo(options = {}) param1 = options[:param1] param2 = options[:param2] return [param1, param2] end > foo param1: "Hello", param2: "World" => ["Hello", "World"]
  • 14. def foo(param1: nil, param2: nil) return [param1, param2] end > foo param1: "Hello", param2: "World" => ["Hello", "World"]
  • 17. module Foo def self.included(base) base.class_eval do alias_method :original_to_s, :to_s def to_s original_to_s + ", Foo" end end end end class Array include Foo end
  • 18. > [1,2,3].to_s => "[1, 2, 3], Foo" > Array.ancestors => [Array, Foo, Enumerable, Object, Kernel, BasicObject]
  • 19. module Foo def to_s super + ", Foo" end end class Array prepend Foo end
  • 20. > [1,2,3].to_s => "[1, 2, 3], Foo" > Array.ancestors => [Foo, Array, Enumerable, Object, Kernel, BasicObject]
  • 22. > a = (0..3).map { |i| i } => [0, 1, 2, 3]
  • 23. > a = (0..3).lazy.map { |i| i } => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..3>:map> > a.next => 0 > a.next => 1 > a.next => 2 > a.next => 3
  • 24. > a = (0..Float::INFINITY).lazy.map { |i| i } => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..Infinity>:map> > a.next => 0 > a.next => 1 > a.next => 2 > a.next => 3
  • 26. module Foo def hello "Hello, #{to_s}" end end class Array include Foo end > [1,2,3].hello => "Hello, [1, 2, 3]"
  • 27. module Foo refine Array do def hello "Hello, #{to_s}" end end end using Foo > [1,2,3].hello => "Hello, [1, 2, 3]"
  • 28. module Foo def bah refine Array do [1,2,3].hello def hello end "Hello, #{to_s}" end > bah.hello end NoMethodError: undefined end method `hello' for "Hello, [1, 2, using Foo 3]":String > [1,2,3].hello => "Hello, [1, 2, 3]"
  • 30. curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
  • 31.
  • 32.
  • 33.
  • 34.
  • 36.
  • 37.
  • 38.
  • 39.
  • 45. Browser Browser Browser Browser NGINX Worker Worker Worker Worker Rails Rails Rails Rails Ruby Ruby Ruby Ruby Linux
  • 46. Browser Browser Browser Browser NGINX Worker Worker Worker Worker Rails Rails Rails Rails Ruby Ruby Ruby Ruby Linux
  • 48. struct RBasic { VALUE flags; RString flags VALUE klass; klass };
  • 49. RString RString RString flags flags flags klass klass klass
  • 50. RString RString RString flags flags flags klass klass klass fork()
  • 51. RString RString RString flags flags flags klass klass klass fork()
  • 52. RString RString RString flags flags flags klass klass klass GC.start() RString RString RString flags flags flags klass klass klass
  • 53. OOBW Out of Band Work
  • 54.
  • 55.
  • 56. Lazy Lazy Sweep GC - Ruby 1.9.3
  • 58. RString RString RString flags flags flags klass klass klass
  • 59. RString RString RString flags flags flags klass klass klass
  • 60. RString RString RString flags flags flags klass klass klass
  • 61. RString RString RString flags flags flags klass klass klass
  • 62.
  • 64.
  • 65.
  • 66.
  • 67.
  • 69.
  • 70.
  • 71.
  • 72.
  • 74.
  • 75.
  • 76. 9 00001001 8 00001000 7 00000111
  • 77. 9 00001001 8 00001000 7 00000111
  • 78. 9 00001001 8 00001000 7 00000111
  • 79.
  • 80. 00000001 2^0 1 User 00000010 2^1 2 Moderator 00000100 2^2 4 Administrator
  • 81. 00000001 2^0 1 User 00000010 2^1 2 Moderator 00000100 2^2 4 Administrator
  • 82. 00000001 2^0 1 User 00000010 2^1 2 Moderator 00000100 2^2 4 Administrator
  • 83. 1 1 1 0 0 0 0 0 0 0 0
  • 84. 1 1 1 0 0 0 0 0 0 0 0 fork()
  • 87. Browser Browser Browser Browser NGINX Worker Worker Worker Worker Rails Rails Rails Rails Ruby Ruby Ruby Ruby Linux
  • 88. Browser Browser Browser Browser Browser Browser Browser Browser Browser Browser NGINX Worker Worker Worker Worker Worker Worker Worker Worker Worker Worker Rails Rails Rails Rails Rails Rails Rails Rails Rails Rails RubyRuby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Linux
  • 89. Browser Browser Browser Browser Browser Browser Browser Browser Browser Browser NGINX Worker Worker Worker Worker Worker Worker Worker Worker Worker Worker Rails Rails Rails Rails Rails Rails Rails Rails Rails Rails RubyRuby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Ruby Linux
  • 90. Rails 3.2.12+ Rails 4.0