SlideShare a Scribd company logo
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

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked

[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
 

Viewers also liked (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
 

Similar to 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
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmersamiable_indian
 
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
 

Similar to 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
 
ppt9
ppt9ppt9
ppt9
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
 
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
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 

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