Slide 1

Slide 1 text

…from a PHP guy What About Ruby on Rails? 1

Slide 2

Slide 2 text

Michael Cheng Software Engineer, Neo Innovation Inc. http://twitter.com/coderkungfu http://github.com/miccheng http://CoderKungfu.com 2

Slide 3

Slide 3 text

Speaker Deck 3 http://bit.ly/rorfromphp

Slide 4

Slide 4 text

About Me • Self-learned front-end / back-end / iOS developer • Building web apps since 2001 • Started Singapore PHP User Group in 2006 • Co-founded iOS Dev Scout (2012) • Worked in startups: Foound (2010) and mig33 (2012) • Joined Neo Innovation Inc. in March 2014 4

Slide 5

Slide 5 text

Ruby on Rails vs PHP? 5

Slide 6

Slide 6 text

Its an unfair comparison… • Ruby on Rails in a software framework written in Ruby (a programming language) • PHP is a programming language
 … or so it thinks… :) • Should compare Ruby vs PHP? • Or Rails vs CakePHP/Symfony/Laravel 6

Slide 7

Slide 7 text

Ruby • A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write • Created by Yukihiro “Matz” Matsumoto • Public release in 1995 • Currently version 2.1.3 • Ruby on Rails released in 2004 7

Slide 8

Slide 8 text

PHP • Created in 1994 by Rasmus Lerdorf as a collection of CGI scripts written in C • In 1997, Andi Gutmans and Zeev Suraski of Tel Aviv, Israel started a complete rewrite of the parser - first steps to becoming a real language • Released PHP 3 in 1998 - Changed meaning to “PHP: Hypertext Preprocessor” • Currently version 5.6.2 8

Slide 9

Slide 9 text

Ruby vs PHP? 9

Slide 10

Slide 10 text

Similarities • Interpreted languages • Dynamically typed • Easy to understand syntax • Object oriented 10

Slide 11

Slide 11 text

Differences • PHP • Web centric • Not quite a language - collection of functions • Ruby • General purpose (more effort to make web) • An expressive programming language 11

Slide 12

Slide 12 text

Specifics… 12 “A string” “Hello, $name” 42 3.146 $variable $obj->variable Klass::$static_var SOME_CONSTANT Klass::SOME_CONST “A string” “Hello #{name}” 42 3.146 local_variable $global_var Klass.class_var SAME_CONSTANT Klass::SOME_CONST

Slide 13

Slide 13 text

Specifics… 13 array(10, 20, 30) array(1, 2, 3, 4, 5) array( “a” => “Apple”, “b” => “Banana” ) [10, 20, 30] [1..5] { a: “Apple”, b: “Banana” }

Slide 14

Slide 14 text

Specifics… 14 if($morning == true){ echo “Hullo” } if ($morning) echo “Hullo” if morning? puts “Hullo” end puts “Hullo” if morning?

Slide 15

Slide 15 text

Specifics… 15 class Tea extends Beverages{ private $water private $milk public function __construct(){ $this->water = true; $this->milk = true; } public function is_good(){ return true; } } class Tea < Beverages def initialize @water = true @milk = true end def good? true end private def secret “hello” end end

Slide 16

Slide 16 text

Other similarities… • Console (irb / php interative shell) • Debugging (pry / phpdbg) • Testing (TestUnit, Rspec / PHPUnit) 16

Slide 17

Slide 17 text

Other similarities… • Healthy open source ecosystem • http://rubygems.org/ & https:// www.ruby-toolbox.com/ • http://packagist.org • Dependency management / packaging • Bundler / Composer 17

Slide 18

Slide 18 text

What I like about Ruby? • Ecosystem • Problems solved by smart people • Tools for developer happyness • Debugging, Testing • Packaging, dependency management • Deployment • Running multiple versions on the same machine 18

Slide 19

Slide 19 text

What I like about Ruby? • Testing • Unit testing • Feature testing • Mocking / Stubbing 19

Slide 20

Slide 20 text

Ruby on Rails 20

Slide 21

Slide 21 text

What about Rails? • Front-end web application framework • An opinion on how to build a web app • Convention over configuration • MVC • Big on testing • Unit, behaviour, feature 21

Slide 22

Slide 22 text

What about Rails? • Running tasks are easy • Emailers are easy • Track DB schema changes easily • Command line interface 22

Slide 23

Slide 23 text

What about Rails? • "There's a Gem for that”TM • Problems already solved • Usually drop in solutions with minimal tweaking (defaults are good enough) 23

Slide 24

Slide 24 text

PHP: We invent the wheel • We have full control & knowledge of how things work • Usually because we had to code it ourselves by hand • Even when you use a framework like CakePHP, Laravel, Symfony… you still have to write a lot of code 24

Slide 25

Slide 25 text

RoR: We invented Automagic • It works like magic • It works, provides for common use cases & standards • It's usually relatively secure & production ready out of the box • Really lends itself to rapid development, MVP 25

Slide 26

Slide 26 text

RoR: We invented Automagic • Example: • Devise - Login, registration, password reset, emails, timeout, etc. • CarrierWave - File upload, S3 support, custom URL, thumbnails, etc. 26

Slide 27

Slide 27 text

Benefits • Faster ramp-up for building your web app • Commonly used stuff are already build - just add the Gem, configure and go! • From idea to product in short time - and its relatively secure and beta tester ready • Easier deployment options • PaaS - Heroku, Azure • Self host via VPS, shared hosting 27

Slide 28

Slide 28 text

Benefits • Continuous Integration/Deployment friendly • Easily testable - ensure your product does what its supposed to • Flexible DB options • Easy to Google / StackOverflow for solutions • CLI FTW! 28

Slide 29

Slide 29 text

Downside • Quite memory intensive • Mostly solvable by throwing machines at the problem. :p (i.e. more money) 29

Slide 30

Slide 30 text

Where to start? • TryRuby • http://tryruby.org • RailsCast • http://railscasts.com/ • Ruby Meetup • http://www.meetup.com/Singapore- Ruby-Group/ 30

Slide 31

Slide 31 text

Where to start? • Rails Girls Singapore • http://railsgirls.com/singapore • http://www.meetup.com/Singapore-Ruby- Group/events/213119462/ • Sat, 25 Oct 2014 @ ThoughtWorks Singapore (87B, Amoy Street, #03/04) 31

Slide 32

Slide 32 text

http://www.neo.com/jobs#Singapore We’re Hiring! 32