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

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

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

Recently uploaded

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

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