SlideShare a Scribd company logo
1 of 38
INTRODUCING RUBY
WHO IS THIS GUY?
   James Thompson
    @plainprogrammer
 james@plainprograms.com

Web Administrator & Student
  @ New Orleans Baptist
   Theological Seminary
WHAT IS RUBY?
 Ruby is a dynamic, open source programming language
with a focus on simplicity and productivity – ruby-lang.org
HISTORY
Created by Yukihiro “matz” Matsumoto

Started development in 1993

First public release in 1995 (Japan)

First English release in 1998

“make Ruby natural, not simple.”
CURRENT STATE
Legacy Stable: 1.8.7p72

Current Stable: 1.9.1p129

A community in transition

Alternatives to MRI
INSTALLING RUBY
•Windows: Cygwin is the best option. One-click installer
available but out of date.

•Linux: apt-get install ruby rdoc irb
•OS X: Already installed in 10.5. Available through
MacPorts as well.
LEARNING RUBY
RUBY’S COMMANDS

•ruby main interpreter
•irb interactive ruby shell
•ri ruby information, manpages for classes
•rdoc ruby documentation compiler
•erb ruby templating system
RUBY CONVENTIONS

•variable_name
•method_name
•ClassName
•ModuleName
•ConstantName | CONTSTANT_NAME
RUBY SYNTAX
OBJECT
ORIENTATION
                                   5.class         #=>   Fixnum
In ruby everything is an object.   3.9.class       #=>   Float
                                   "Hello".class   #=>   String
                                   Fixnum.class    #=>   Class
  This is both powerful and
                                   nil.class       #=>   NilClass
           different.
SYMBOLS

:a_symbol

opts = {
    :a_key => "Some value!",
    :another_key => "another value..."
  }
INSTANCE & CLASS VARIABLES


     @instance_variable
     @@class_variable
STRINGS
name = 'BarCamp Joe'
greeting = "Hello, #{name}!"

long_greeting <<-EOS
  Hello my old friend, #{name}!
  How have you been?
EOS

alternate_greeting = %{G'day, #{name.upcase}!}
NUMBERS

a   =   1
b   =   2.0
c   =   2.3e5
d   =   0x3F
e   =   0244
METHODS

def say_hello(name)
  result = "Hello, #{name}!"
end

puts say_hello("BarCamp NOLA")
METHODS

def say_hello(name)
  result = "Hello, #{name}"
  return result
end

puts say_hello("BarCamp NOLA")
CLASSES

class Greeter
  def say_hello(name)
    puts "Hello, #{name}!"
  end
end

doorman = Greeter.new

doorman.say_hello("BarCampers")
CLASSES

class RudeGreeter < Greeter
  def say_hello(name)
    puts ""
  end
end
CLASSES

class Greeter
  def initialize(name)
    @greeters_name = name
  end
end
CLASSES

class Greeter
  attr_reader :name
end

doorman.name
CLASSES

class RudeGreeter < Greeter
  def initialize(name, rudeness)
    @rudeness = rudeness
    super(name)
  end
end
MODULES

module Farewell
  def bid_farewell(name)
    "Good bye, #{name}!"
  end
end
MODULES

class Greeter
  include Farewell
end

doorman = Greeter.new("John")
doorman.bid_farewell("BarCampers")
CLASS/MODULE MUTABILITY

  class Numeric
    def plus(n)
      self.+(n)
    end
  end

  y = 5.plus 6    #=> 11
CONTROL STRUCTURES
 if "a" == "a"
   puts "a"
 end

 unless "a".nil?
   puts "a"
 end

 puts "a" unless "a".nil?

 name = case
   when num == 1: "one"
   when num == 2: "two"
   else
     num.to_s
 end

 [1,2,3].each do |value|
   puts value.to_s
 end
TYPES
•Numbers
•Strings
•Regular Expressions (/^(foo|bar)+$/)
•Arrays ([1,2,3])
•Hashes
•Ranges (1..10, "a"..."z")
•Symbols
BLOCKS, PROCS & LAMBDAS

  [1,2,3].each do |value|
    puts value.to_s
  end

  square = Proc.new do |n|
    n ** 2
  end
RUBYGEMS
CPAN      Pear   PECL              RAA   Rubyforge   Github     PyPI

17,000


12,750


 8,500


 4,250

                                 Obsolete
    0
                Perl             Ruby                Python            PHP




   PERL, PHP & RUBY PACKAGES
SEEING WHAT’S OUT THERE


  gem list --remote

  gem list
GETTING HELP


gem help
gem help commands
INSTALLING GEMS

gem install rails

gem install mysql sqlite3-ruby

gem install rails --no-ri --no-rdoc
COMMANDS FOR GEMS


rails --version
REMOVING GEMS


gem uninstall mysql
WHY USE RUBY?
QUESTIONS?
MORE RESOURCES

    ruby-lang.org
    ruby-doc.org
    rubygems.org
    rubyforge.org
    pragprog.com

More Related Content

What's hot

Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - IntroductionKwangshin Oh
 
Ruby Presentation
Ruby Presentation Ruby Presentation
Ruby Presentation platico_dev
 
Ruby for Java Developers
Ruby for Java DevelopersRuby for Java Developers
Ruby for Java DevelopersRobert Reiz
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentationadamcookeuk
 
Ruby An Introduction
Ruby An IntroductionRuby An Introduction
Ruby An IntroductionShrinivasan T
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentationManav Prasad
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 

What's hot (13)

Ruby on Rails for beginners
Ruby on Rails for beginnersRuby on Rails for beginners
Ruby on Rails for beginners
 
Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - Introduction
 
Ruby Presentation
Ruby Presentation Ruby Presentation
Ruby Presentation
 
Ruby for Java Developers
Ruby for Java DevelopersRuby for Java Developers
Ruby for Java Developers
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
Ruby
RubyRuby
Ruby
 
Ruby An Introduction
Ruby An IntroductionRuby An Introduction
Ruby An Introduction
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt9
ppt9ppt9
ppt9
 
ppt18
ppt18ppt18
ppt18
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 

Viewers also liked

20081128 Bee
20081128 Bee20081128 Bee
20081128 Beecemera
 
Presentation Jalase 1
Presentation Jalase 1Presentation Jalase 1
Presentation Jalase 1shivani1357
 
Srategic triangulation past, present and possible
Srategic triangulation   past, present and possibleSrategic triangulation   past, present and possible
Srategic triangulation past, present and possibleSharon Johnson
 
Presentacion Power Point
Presentacion Power PointPresentacion Power Point
Presentacion Power Pointandrelg1990
 
Helath mangement in business
Helath mangement in business Helath mangement in business
Helath mangement in business Hélder Silva
 
テレビや新聞に未来はあるか
テレビや新聞に未来はあるかテレビや新聞に未来はあるか
テレビや新聞に未来はあるかguestf7fcfc7
 
Organizational change tensions
Organizational change tensionsOrganizational change tensions
Organizational change tensionsSharon Johnson
 
Systems foundations to organizational change and development
Systems foundations to organizational change and developmentSystems foundations to organizational change and development
Systems foundations to organizational change and developmentSharon Johnson
 
Learn Ruby 2011 - Session 3
Learn Ruby 2011 - Session 3Learn Ruby 2011 - Session 3
Learn Ruby 2011 - Session 3James Thompson
 
Before & After Project Ed 546 & 548
Before & After Project Ed 546 & 548Before & After Project Ed 546 & 548
Before & After Project Ed 546 & 548weisenhornkm
 
A systems approach to leading change
A systems approach to leading changeA systems approach to leading change
A systems approach to leading changeSharon Johnson
 

Viewers also liked (20)

Seo search engine_optimisation
Seo search engine_optimisationSeo search engine_optimisation
Seo search engine_optimisation
 
Fantastic Trip
Fantastic TripFantastic Trip
Fantastic Trip
 
20081128 Bee
20081128 Bee20081128 Bee
20081128 Bee
 
Presentation Jalase 1
Presentation Jalase 1Presentation Jalase 1
Presentation Jalase 1
 
Srategic triangulation past, present and possible
Srategic triangulation   past, present and possibleSrategic triangulation   past, present and possible
Srategic triangulation past, present and possible
 
Presentacion Power Point
Presentacion Power PointPresentacion Power Point
Presentacion Power Point
 
Helath mangement in business
Helath mangement in business Helath mangement in business
Helath mangement in business
 
テレビや新聞に未来はあるか
テレビや新聞に未来はあるかテレビや新聞に未来はあるか
テレビや新聞に未来はあるか
 
PART I.1 - Physical Mathematics
PART I.1 - Physical MathematicsPART I.1 - Physical Mathematics
PART I.1 - Physical Mathematics
 
Every1
Every1Every1
Every1
 
Organizational change tensions
Organizational change tensionsOrganizational change tensions
Organizational change tensions
 
Systems foundations to organizational change and development
Systems foundations to organizational change and developmentSystems foundations to organizational change and development
Systems foundations to organizational change and development
 
Learn Ruby 2011 - Session 3
Learn Ruby 2011 - Session 3Learn Ruby 2011 - Session 3
Learn Ruby 2011 - Session 3
 
Mobile marketing
Mobile marketingMobile marketing
Mobile marketing
 
Sample: Student Work
Sample: Student WorkSample: Student Work
Sample: Student Work
 
Before & After Project Ed 546 & 548
Before & After Project Ed 546 & 548Before & After Project Ed 546 & 548
Before & After Project Ed 546 & 548
 
Octubre
OctubreOctubre
Octubre
 
Great Films
Great FilmsGreat Films
Great Films
 
A systems approach to leading change
A systems approach to leading changeA systems approach to leading change
A systems approach to leading change
 
Part IX - Supersymmetry
Part IX - SupersymmetryPart IX - Supersymmetry
Part IX - Supersymmetry
 

Similar to Introducing Ruby

Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technologyppparthpatel123
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9sagaroceanic11
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9sagaroceanic11
 
Introduction to the Ruby Object Model
Introduction to the Ruby Object ModelIntroduction to the Ruby Object Model
Introduction to the Ruby Object ModelMiki Shiran
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on railsPriceen
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the BasicsMichael Koby
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmersamiable_indian
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 

Similar to Introducing Ruby (20)

Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Introduction to the Ruby Object Model
Introduction to the Ruby Object ModelIntroduction to the Ruby Object Model
Introduction to the Ruby Object Model
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
 
Ruby
RubyRuby
Ruby
 
Ruby_Basic
Ruby_BasicRuby_Basic
Ruby_Basic
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt17
ppt17ppt17
ppt17
 
ppt30
ppt30ppt30
ppt30
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 

More from James Thompson

Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018James Thompson
 
Bounded Contexts for Legacy Code
Bounded Contexts for Legacy CodeBounded Contexts for Legacy Code
Bounded Contexts for Legacy CodeJames Thompson
 
Beyond Accidental Arcitecture
Beyond Accidental ArcitectureBeyond Accidental Arcitecture
Beyond Accidental ArcitectureJames Thompson
 
Effective Pair Programming
Effective Pair ProgrammingEffective Pair Programming
Effective Pair ProgrammingJames Thompson
 
Wrapping an api with a ruby gem
Wrapping an api with a ruby gemWrapping an api with a ruby gem
Wrapping an api with a ruby gemJames Thompson
 
Microservices for the Monolith
Microservices for the MonolithMicroservices for the Monolith
Microservices for the MonolithJames Thompson
 
Learn Ruby 2011 - Session 4 - Objects, Oh My!
Learn Ruby 2011 - Session 4 - Objects, Oh My!Learn Ruby 2011 - Session 4 - Objects, Oh My!
Learn Ruby 2011 - Session 4 - Objects, Oh My!James Thompson
 
Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1James Thompson
 
Learn Ruby 2011 - Session 2
Learn Ruby 2011 - Session 2Learn Ruby 2011 - Session 2
Learn Ruby 2011 - Session 2James Thompson
 
Rails: Scaling Edition - Getting on Rails 3
Rails: Scaling Edition - Getting on Rails 3Rails: Scaling Edition - Getting on Rails 3
Rails: Scaling Edition - Getting on Rails 3James Thompson
 
Ruby For Web Development
Ruby For Web DevelopmentRuby For Web Development
Ruby For Web DevelopmentJames Thompson
 
Ruby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpecRuby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpecJames Thompson
 

More from James Thompson (13)

Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018
 
Bounded Contexts for Legacy Code
Bounded Contexts for Legacy CodeBounded Contexts for Legacy Code
Bounded Contexts for Legacy Code
 
Beyond Accidental Arcitecture
Beyond Accidental ArcitectureBeyond Accidental Arcitecture
Beyond Accidental Arcitecture
 
Effective Pair Programming
Effective Pair ProgrammingEffective Pair Programming
Effective Pair Programming
 
Wrapping an api with a ruby gem
Wrapping an api with a ruby gemWrapping an api with a ruby gem
Wrapping an api with a ruby gem
 
Microservices for the Monolith
Microservices for the MonolithMicroservices for the Monolith
Microservices for the Monolith
 
Mocking & Stubbing
Mocking & StubbingMocking & Stubbing
Mocking & Stubbing
 
Learn Ruby 2011 - Session 4 - Objects, Oh My!
Learn Ruby 2011 - Session 4 - Objects, Oh My!Learn Ruby 2011 - Session 4 - Objects, Oh My!
Learn Ruby 2011 - Session 4 - Objects, Oh My!
 
Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1
 
Learn Ruby 2011 - Session 2
Learn Ruby 2011 - Session 2Learn Ruby 2011 - Session 2
Learn Ruby 2011 - Session 2
 
Rails: Scaling Edition - Getting on Rails 3
Rails: Scaling Edition - Getting on Rails 3Rails: Scaling Edition - Getting on Rails 3
Rails: Scaling Edition - Getting on Rails 3
 
Ruby For Web Development
Ruby For Web DevelopmentRuby For Web Development
Ruby For Web Development
 
Ruby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpecRuby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpec
 

Recently uploaded

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Introducing Ruby

Editor's Notes

  1. * A dynamic object-oriented programming language * Inspired by Perl, Eiffel, Ada, Lisp and Smalltalk. * Its creator stated his goal was to &quot;make Ruby natural, not simple.&quot; Ruby is a very powerful language that is also very flexible. It is pervasively object-oriented. It is a general purpose language, so it is useful in the same places that Perl, PHP, etc. would be used.
  2. Developed by Yukihiro &quot;matz&quot; Matsumoto in 1993 with its first public release in Japan in 1995. It saw its first English announcement in 1998 and was followed by the publication of the Programming Ruby book in 2000 by Dave Thomas and Andy Hunt. The second edition of Programming Ruby, known as the &quot;Pickaxe Book&quot; was released in 2004.
  3. The Ruby world is transitioning to 1.9 and most major and currently maintained projects have made the switch to supporting 1.9. The community is tracking the progress of this transition with relation to Gems as isitruby19.com Beyond the &quot;official&quot; interpreter, usually referred to as &quot;MRI,&quot; there are a number of projects to develop alternative interpreters for various reasons and to met various needs. * Enterprise: Ruby 1.8 with better memory handling and other performance optimizations * JRuby: Ruby on top of the JVM, fastest 1.8 implementation around. * MacRuby: Ruby on top of Apple&apos;s Objective-C runtime. * IronRuby: Ruby on top of the .NET DLR. * Rubinius: Ruby developed with a tight C++ main interpreter and most of the rest of the language developed the Ruby subset understood by the main interpreter.
  4. If you are on Windows you should use Cygwin. Or, better yet, move to a unix environment since many of the best and most useful Ruby Gems use C extensions which are a pain to get working outside of a unix environment. There is the one-click installer as well, but it is badly outdated, and the straight binary releases from ruby-lang.org. For Linux you can use your favorite package manager to install ruby, irb and rdoc to get the whole base system. Some distros are starting to make 1.9 available but it usually has a suffix on all the commands which make them more cumbersome. For OS X if you have Leopard you already have Ruby available but if you use MacPorts you can get the latest version and even 1.9 with no suffix. Mac users also have access to the MacRuby project which is very promising and should eventually make OS X an even better platform for Rubyists. If you don&apos;t want to install Ruby you can play with an online interactive environment at tryruby.hobix.com.
  5. Ruby&apos;s command set provides a rich set of features for exploring the language, its documentation and different ways of using it.
  6. Ruby has a number of conventions which are collectively referred to as the &quot;Ruby Way.&quot; You are free to ignore these conventions if you like, but don&apos;t expect much love from your fellow Rubyists. And you can expect a nasty warning from the interpreter if you fiddle with what it expects of a constant, although you are actually free to change a constant. Module and Class names are actually constants which is why some consider it acceptable to use camel case for constants as well.
  7. One big thing to understand from the start with Ruby is that everything is an object. With the exception of reserved keywords everything is an object in Ruby. This allows for really interesting programming techniques in terms of chaining method invocation and even manipulation of parameters. Object is the parent of all classes. Duck typing is the pattern Ruby follows where behavior is closely coupled to type.
  8. Another big thing in Ruby are symbols. Because of Ruby&apos;s object model two strings which have the same character sequences are not the same. They have different object ids and occupy separate places in memory. Some have described symbols as immutable strings but this is really an oversimplification. Used with hashes for keys and as pseudo-constants. There is a lot more to symbols and whole blogs have focused on uses for symbols so go Google Ruby symbols if you want to learn more.
  9. If you are working with a class you have two special kinds of variables available to you. Instance variables are unique to a particular instance of an object while class variables are unique to all instances of a given class.
  10. Strings are really straight forward. Ruby supports single and double quoted strings, as well as HEREDOC style strings and alternative encapsulated strings. Strings also support interpolation of variables as well. Escaped new lines are optional when using certain ruby methods. Most of the time you don&apos;t need to be explicit with new lines, Ruby uses them where you would expect automatically.
  11. Ruby deals well with integers and floating point values as you would expect. It supports decimal and scientific notation as well as hex and octal.
  12. Something that is missing that some may wonder about is an explicit return. In Ruby the last expression within a method is returned as the result of the method by default. So explicit returns are not needed. You can do an explicit return however.
  13. A thing to note about Ruby classes is that they only support single inheritance, although there is an inheritance hierarchy at work in Ruby. Inheritance is also pretty straightforward to achieve.
  14. The way you call the constructor is by using the new method. To define a constructor for a class just define a method called initialize.
  15. You can also define attributes for classes. These are just set/get accessors for the class, if defined they are usually tied to an instance variable.
  16. You can invoke any inherited methods by calling super().
  17. Modules are collections of methods and constants. They are used to achieve much the same ends as multiple inheritance would provide but without the confusion.
  18. Modules get mixed in to classes using the include method.
  19. Something you should have noticed if you were following along with the code examples in irb is that I didn&apos;t redefine the entire class every time I did something new. One of the most useful and potentially troublesome features of Ruby is the open nature of classes and modules. You can just open them up and add to them. Heck, there are even ways to remove methods and the like. Here&apos;s an example of a modification to the way numbers work in Ruby. You can add and redefine methods on any class or module very easily in Ruby. Again, this is a very powerful but also dangerous capability.
  20. Ruby has all the typical control structures and some of its own interesting ones. That last one is a fun way to work with collections like arrays or hashes.
  21. Ruby has all the types you would expect from a good dynamic language. Most we&apos;ve already discussed but here&apos;s a quick rundown of the standard ones, including some we didn&apos;t talk about.
  22. Ruby supports closures in the forms of blocks, procs and lambdas. Blocks are basically pieces of code that you can pass as arguments to method calls. We saw a basic block with control structures. You can think of blocks like anonymous methods that are able to capture the context they are called in. Procs are essentially blocks that have been stored in a variable. This allows a the Proc to be more reusable than a block and allows the developer to avoid repetition. Ruby also provides lambdas which are similar to Procs but check the number of variables passed to them. For more on these three special structures in Ruby you can Google them and learn all the different ways they can be used.
  23. The best way to think of RubyGems is to think of it like CPAN for Ruby. It is the de facto standard for distributing reusable Ruby code. Lots of libraries, and most Ruby applications are distributed as Gems. You can get RubyGems either by default with Ruby 1.9 or downloaded from rubygems.org. But lets look at how you use RubyGems a little bit. Many Linux distros also have it available as a package.
  24. When compared to the package repositories of other popular languages Ruby is definitely a productive community. The numbers for Github may give a slightly exaggerated impression since many of the gems hosted with them are duplicates of gems distributed through Rubyforge or are unstable development packages. However, it is clear that Ruby is a healthy community of users sharing their work with one another.