SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Ruby for PHP
Developers


                      By Max Titov
                       maxtitov.me
         Ninja Software Operations
Objective: learn and compare
▶   What is Ruby and where it is come from?
▶   Why Ruby?
▶   Ruby basics
▶   Ruby ecosystem
▶   Ruby specialties
▶   How to get started?
Facts
▶   First “Hello World” in 1995 (PHP 1995 too)
▶   Opensource (PHP too)
▶   Inspired by: Perl, Smalltalk, Lisp, Python …
▶   Philosophy: Designed for programmer
    productivity and fun.
Creator
"I wanted a scripting language that was
more powerful than Perl, and more object-
oriented than Python. That's why I decided
to design my own language.”

 Yukihiro (Matz) Matsumoto
Why Ruby?
▶   It’s fun!
▶   It’s going to make your better.
▶   And definitely it will sabotage what you
    believe in.
Similarities
▶   Ruby has exception handling
▶   Garbage collector
▶   The is fairly large standard library
▶   The are classes and access modifiers
Ruby is Dynamic
▶   No need to declare variables

var = “World in hell”
var.class #String
var = 1
var.class #Fixnum
Ruby is Strong Typed
▶   Like in Java or C# there is no type
    juggling.
    You need to convert between types.

a = “1”
b=2
a + b #TypeError: can't convert Fixnum into String
a.to_i + b # 3
Everything is an Object
▶   Inspired by SmallTalk
▶   Unlike other programming languages that
    states the same, Ruby really is.
Everything is an Object
▶   Primitive Types are an objects

10.times {puts “I am sexy and I know it!”}
#Output “I am sexy and I know it!”
#Output “I am sexy and I know it!”
#Output “I am sexy and I know it!”
#Output “I am sexy and I know it!”
#Output “I am sexy and I know it!”
#....(10 times)…
Everything is an Object
▶   Control structures are object methods

    class Fixnum < Integer
       def – numeric
         # subtracting code
       end
    end
Ruby is Flexible
▶   Existing ruby code could be easily altered.

    class Numeric
       def toSquare
         self * self
       end
    end

    2.toSquare# 4
Duck typing
▶   Definition: When I see a bird that walks
    like a duck and swims like a duck and
    quacks like a duck, I call that bird a duck.
    (Wikipedia)
Duck typing
What makes object an object?

        Answer is a:


 Behavior
So, is it a duck?

Swim? Yes
Can Quack? Yes

Is it a duck?
Definitely!
And this?

Swim? Yes
Can Quack? Yes. Kind of
strange, but still it
make quack like sound

Is it a duck?
Looks like!
How, about this?

Swim? Badly, but yes.
Can Quack? Yeah, make
Plenty of sounds but, can
quack also.

Is it a duck?
Sort of weird duck, but yes!
Or, probably this?

Swim? Yep
Can quack? Can
make weird quack
sounds.

Is it duck?
Trying very hard, so
yes 
Duck Typing
▶   So, everything that could respond to
    several criteria's that makes us believe
    that it’s a duck, is a duck.
Duck Typing in context of Ruby
▶   There is no abstract classes and
    interfaces.
▶   There is Modules and Mixins.
Modules and Mixins
▶   Modules define reusable pieces of code
    that couldn’t be instantiated.
▶   Modules provides a namespace and
    prevent name clashes
▶   Modules could be “mixin” to any class that
    satisfy conventions described in
    documentation (Should quack and swim
    like a duck).
▶   In PHP 5.4 Traits is an equivalent to
    Mixins
How we usually do this in PHP
Interface ILog
{
    function write($message)
}

EventLog implements ILog
{
   function write($message)
   {
      //useful code
   }
}
How we do this in Ruby
module Log
  def write
   #code
  end
End

class EventLog
   include Log
   def Prepare
   end
end
Implementing Enumerable
▶   From Enumerable module documentation:
    The Enumerable mixin provides collection
    classes with several traversal and
    searching methods, and with the ability to
    sort. The class must provide a method
    “each”, which
    yields successive members of the
    collection.
Implementing Enumerable
class MyCollection
   include Enumerable
   def each
      #yields result
   end
end
About coding guide lines
▶   Remember the times of Hungarian
    notation?
        $f_amount = 100.00;
        $s_string = “I am definitely a string”;
▶   How many coding guide lines there?
    ▶   PEAR,
    ▶   Zend,
    ▶   Wordpress
    ▶   Your company standard
You. When you get someone's code
  with different coding guide lines.
Ruby Coding guide lines
Ruby syntaxes mostly dictates coding
guidelines:
  ▶   localVariable
  ▶   @instanceVariable
  ▶   @@classVariable
  ▶   $globalVariable
  ▶   Constant
  ▶   ClassName
  ▶   method_name
Ruby metaprogramming
▶   DRY – Don’t repeat yourself.
▶   But that’s another story 
Frameworks
Ruby                    PHP
▶   Ruby on             ▶   Symfony, Yii, Zend
    Rails, Merb             …
▶   Sinatra             ▶   Sylex
▶   Radiant, Mephisto   ▶   WordPress, Drupal
                            , Joomla
Tools
Ruby                     PHP
▶   Ruby Gems            ▶   PEAR, Composer
▶   Bundler              ▶   Bash, Composer
▶   TestUnit, minitest   ▶   PHPUnit
▶   Cucumber, Rspec,     ▶   Behat
    Shoulda
Testing Rocks!
Feel like a Rubier now?
Ruby tutorial 101
Interactive ruby tutorial:
▶ http://tryruby.org/



Online course:
▶ http://www.coursera.org/course/saas/

▶
Books
▶   Programming Ruby (Pick Axe book)
By Thomas D., Fowler C., Hunt A.

▶   Design Patterns In Ruby
By Russ Olsen

▶   Search Google for: Learn Ruby
Follow the ruby side
 we have cookies
        
Questions?
   Ruby for PHP developers
          By Max Titov
Get examples: www.maxtitov.me
Get in touch: eolexe@gmail.com
         Twitter: eolexe

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!Iván López Martín
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Rormyuser
 
Constructors, Intro to Ruby Classes Part II
Constructors, Intro to Ruby Classes Part IIConstructors, Intro to Ruby Classes Part II
Constructors, Intro to Ruby Classes Part IIJuan Leal
 
Intro Ruby Classes Part I
Intro Ruby Classes Part IIntro Ruby Classes Part I
Intro Ruby Classes Part IJuan Leal
 
An Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersAn Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersKostas Saidis
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript TipsTroy Miles
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorialknoppix
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?daoswald
 
6 Modules Inheritance Gems
6 Modules Inheritance Gems6 Modules Inheritance Gems
6 Modules Inheritance Gemsliahhansen
 
On the path to become a jr. developer short version
On the path to become a jr. developer short versionOn the path to become a jr. developer short version
On the path to become a jr. developer short versionAntonelo Schoepf
 
Language portfolio
Language portfolioLanguage portfolio
Language portfolioDhaval Dalal
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, DarrrtJana Moudrá
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyMark Menard
 
Add Perl to Your Toolbelt
Add Perl to Your ToolbeltAdd Perl to Your Toolbelt
Add Perl to Your Toolbeltdaoswald
 
Ruby on Rails: a brief introduction
Ruby on Rails: a brief introductionRuby on Rails: a brief introduction
Ruby on Rails: a brief introductionLuigi De Russis
 

Was ist angesagt? (20)

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Constructors, Intro to Ruby Classes Part II
Constructors, Intro to Ruby Classes Part IIConstructors, Intro to Ruby Classes Part II
Constructors, Intro to Ruby Classes Part II
 
Backend roadmap
Backend roadmapBackend roadmap
Backend roadmap
 
Intro Ruby Classes Part I
Intro Ruby Classes Part IIntro Ruby Classes Part I
Intro Ruby Classes Part I
 
An Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersAn Introduction to Groovy for Java Developers
An Introduction to Groovy for Java Developers
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
 
6 Modules Inheritance Gems
6 Modules Inheritance Gems6 Modules Inheritance Gems
6 Modules Inheritance Gems
 
Oops
OopsOops
Oops
 
On the path to become a jr. developer short version
On the path to become a jr. developer short versionOn the path to become a jr. developer short version
On the path to become a jr. developer short version
 
Language portfolio
Language portfolioLanguage portfolio
Language portfolio
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Add Perl to Your Toolbelt
Add Perl to Your ToolbeltAdd Perl to Your Toolbelt
Add Perl to Your Toolbelt
 
Ruby on Rails: a brief introduction
Ruby on Rails: a brief introductionRuby on Rails: a brief introduction
Ruby on Rails: a brief introduction
 

Andere mochten auch

[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward
[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward
[HUBFORUM Paris] BuzzFeed Presents the native truth - Will HaywardHUB INSTITUTE
 
Ajax Technology
Ajax TechnologyAjax Technology
Ajax TechnologyZia_Rehman
 
Multiquery optimization on spark
Multiquery optimization on sparkMultiquery optimization on spark
Multiquery optimization on sparkBự Bụng
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

Andere mochten auch (7)

Ajax
AjaxAjax
Ajax
 
[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward
[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward
[HUBFORUM Paris] BuzzFeed Presents the native truth - Will Hayward
 
Ajax Technology
Ajax TechnologyAjax Technology
Ajax Technology
 
121008 cbs hv bovern 2
121008 cbs hv bovern 2121008 cbs hv bovern 2
121008 cbs hv bovern 2
 
Multiquery optimization on spark
Multiquery optimization on sparkMultiquery optimization on spark
Multiquery optimization on spark
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Ähnlich wie Ruby for PHP developers

Ruby object model
Ruby object modelRuby object model
Ruby object modelmbeizer
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsNicolas Demengel
 
Building reusable components with generics and protocols
Building reusable components with generics and protocolsBuilding reusable components with generics and protocols
Building reusable components with generics and protocolsDonny Wals
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Codeeddiehaber
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Justin Lin
 
Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Wen-Tien Chang
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010ssoroka
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 

Ähnlich wie Ruby for PHP developers (20)

Ruby object model
Ruby object modelRuby object model
Ruby object model
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 
Ruby Hell Yeah
Ruby Hell YeahRuby Hell Yeah
Ruby Hell Yeah
 
Building reusable components with generics and protocols
Building reusable components with generics and protocolsBuilding reusable components with generics and protocols
Building reusable components with generics and protocols
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.
 
Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
 
Ruby Metaprogramming 08
Ruby Metaprogramming 08Ruby Metaprogramming 08
Ruby Metaprogramming 08
 
Cucumber in Practice(en)
Cucumber in Practice(en)Cucumber in Practice(en)
Cucumber in Practice(en)
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
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
 

Kürzlich hochgeladen

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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 organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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...Neo4j
 
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 AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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 Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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 WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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...
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Ruby for PHP developers

  • 1. Ruby for PHP Developers By Max Titov maxtitov.me Ninja Software Operations
  • 2. Objective: learn and compare ▶ What is Ruby and where it is come from? ▶ Why Ruby? ▶ Ruby basics ▶ Ruby ecosystem ▶ Ruby specialties ▶ How to get started?
  • 3.
  • 4. Facts ▶ First “Hello World” in 1995 (PHP 1995 too) ▶ Opensource (PHP too) ▶ Inspired by: Perl, Smalltalk, Lisp, Python … ▶ Philosophy: Designed for programmer productivity and fun.
  • 5. Creator "I wanted a scripting language that was more powerful than Perl, and more object- oriented than Python. That's why I decided to design my own language.” Yukihiro (Matz) Matsumoto
  • 6. Why Ruby? ▶ It’s fun! ▶ It’s going to make your better. ▶ And definitely it will sabotage what you believe in.
  • 7. Similarities ▶ Ruby has exception handling ▶ Garbage collector ▶ The is fairly large standard library ▶ The are classes and access modifiers
  • 8. Ruby is Dynamic ▶ No need to declare variables var = “World in hell” var.class #String var = 1 var.class #Fixnum
  • 9. Ruby is Strong Typed ▶ Like in Java or C# there is no type juggling. You need to convert between types. a = “1” b=2 a + b #TypeError: can't convert Fixnum into String a.to_i + b # 3
  • 10. Everything is an Object ▶ Inspired by SmallTalk ▶ Unlike other programming languages that states the same, Ruby really is.
  • 11. Everything is an Object ▶ Primitive Types are an objects 10.times {puts “I am sexy and I know it!”} #Output “I am sexy and I know it!” #Output “I am sexy and I know it!” #Output “I am sexy and I know it!” #Output “I am sexy and I know it!” #Output “I am sexy and I know it!” #....(10 times)…
  • 12. Everything is an Object ▶ Control structures are object methods class Fixnum < Integer def – numeric # subtracting code end end
  • 13. Ruby is Flexible ▶ Existing ruby code could be easily altered. class Numeric def toSquare self * self end end 2.toSquare# 4
  • 14. Duck typing ▶ Definition: When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck. (Wikipedia)
  • 15. Duck typing What makes object an object? Answer is a: Behavior
  • 16. So, is it a duck? Swim? Yes Can Quack? Yes Is it a duck? Definitely!
  • 17. And this? Swim? Yes Can Quack? Yes. Kind of strange, but still it make quack like sound Is it a duck? Looks like!
  • 18. How, about this? Swim? Badly, but yes. Can Quack? Yeah, make Plenty of sounds but, can quack also. Is it a duck? Sort of weird duck, but yes!
  • 19. Or, probably this? Swim? Yep Can quack? Can make weird quack sounds. Is it duck? Trying very hard, so yes 
  • 20. Duck Typing ▶ So, everything that could respond to several criteria's that makes us believe that it’s a duck, is a duck.
  • 21. Duck Typing in context of Ruby ▶ There is no abstract classes and interfaces. ▶ There is Modules and Mixins.
  • 22. Modules and Mixins ▶ Modules define reusable pieces of code that couldn’t be instantiated. ▶ Modules provides a namespace and prevent name clashes ▶ Modules could be “mixin” to any class that satisfy conventions described in documentation (Should quack and swim like a duck). ▶ In PHP 5.4 Traits is an equivalent to Mixins
  • 23. How we usually do this in PHP Interface ILog { function write($message) } EventLog implements ILog { function write($message) { //useful code } }
  • 24. How we do this in Ruby module Log def write #code end End class EventLog include Log def Prepare end end
  • 25. Implementing Enumerable ▶ From Enumerable module documentation: The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method “each”, which yields successive members of the collection.
  • 26. Implementing Enumerable class MyCollection include Enumerable def each #yields result end end
  • 27. About coding guide lines ▶ Remember the times of Hungarian notation? $f_amount = 100.00; $s_string = “I am definitely a string”; ▶ How many coding guide lines there? ▶ PEAR, ▶ Zend, ▶ Wordpress ▶ Your company standard
  • 28. You. When you get someone's code with different coding guide lines.
  • 29. Ruby Coding guide lines Ruby syntaxes mostly dictates coding guidelines: ▶ localVariable ▶ @instanceVariable ▶ @@classVariable ▶ $globalVariable ▶ Constant ▶ ClassName ▶ method_name
  • 30. Ruby metaprogramming ▶ DRY – Don’t repeat yourself. ▶ But that’s another story 
  • 31. Frameworks Ruby PHP ▶ Ruby on ▶ Symfony, Yii, Zend Rails, Merb … ▶ Sinatra ▶ Sylex ▶ Radiant, Mephisto ▶ WordPress, Drupal , Joomla
  • 32. Tools Ruby PHP ▶ Ruby Gems ▶ PEAR, Composer ▶ Bundler ▶ Bash, Composer ▶ TestUnit, minitest ▶ PHPUnit ▶ Cucumber, Rspec, ▶ Behat Shoulda
  • 34. Feel like a Rubier now?
  • 35. Ruby tutorial 101 Interactive ruby tutorial: ▶ http://tryruby.org/ Online course: ▶ http://www.coursera.org/course/saas/ ▶
  • 36. Books ▶ Programming Ruby (Pick Axe book) By Thomas D., Fowler C., Hunt A. ▶ Design Patterns In Ruby By Russ Olsen ▶ Search Google for: Learn Ruby
  • 37. Follow the ruby side we have cookies 
  • 38. Questions? Ruby for PHP developers By Max Titov Get examples: www.maxtitov.me Get in touch: eolexe@gmail.com Twitter: eolexe