PHP Guide to Ruby
This guide is tailored to you - the PHP developer. You’ve got a basic grip on PHP as a language and you’re curious about the fuss around Ruby and it’s crown jewel the “king of web apps” Ruby on Rails.
As I learned Ruby and the Rails framework I was confused by the syntax and implicitness of the language. But after the initial hurdles, I’ve come to realize that Ruby and PHP are really not so different after all.
As a PHP developer, especially if you have a grasp on the Object Oriented Programming (OOP), prepare to be mildly surprised how similar this “fancy” language is defined.
You’ll come to find that some of the claims made of Ruby being superior to PHP, such as “meta programming”, are actually just marketing terms.
Everything you can do in PHP can be accomplished with Ruby - and vice versa.
However, as you read through this guide you’ll come to find concrete examples and get a feeling for the philosophy of Developer Happiness First that Ruby so famously concentrates on.
This guide will leverage what you already know about PHP and show rhyming examples in Ruby. It won’t cover 100% of the differences, however by finishing these series of small examples you’ll have more than enough understanding to be productive in the language.
Table of Contents
- Why learn Ruby?
- History and Philosophy of Ruby
- Interacting With Ruby
- Everything is an Object
- String Concatenation and Interpolation
- Comments in Ruby
- Casting to other Datatypes
- Nil vs Null
- If Statements
- Switch Statements
- Object Oriented Programming Basics
- Requiring other Ruby files
- Conclusion & Next Steps