SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

[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
 

En vedette (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
 

Similaire à 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 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 

Similaire à 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
 
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
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 

Dernier

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
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
 
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
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Dernier (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
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?
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
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
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 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