Slide 1

Slide 1 text

Michael Cheng @coderkungfu
 @engineersftw

Slide 2

Slide 2 text

Senior Software Engineer, Singapore Power’s Digital Technologies Team

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Singapore PHP User Group (started in 2007)

Slide 5

Slide 5 text

5 Rasmus Lerdorf, Creator of PHP

Slide 6

Slide 6 text

6 PHPConf.Asia 2015

Slide 7

Slide 7 text

7 Joined Neo Innovation in 2014

Slide 8

Slide 8 text

8 TechLadies Bootcamp (2017) - Mountbatten Vocational School

Slide 9

Slide 9 text

9 Yukihiro Matsumoto, Creator of Ruby

Slide 10

Slide 10 text

MVC Web Frameworks in PHP 10

Slide 11

Slide 11 text

Ruby vs PHP? 11

Slide 12

Slide 12 text

Similarities • Interpreted languages • Dynamically typed • Easy to understand syntax • Object Oriented 12

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Syntax Compared 14 “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 SOME_CONSTANT Klass::SOME_CONST

Slide 15

Slide 15 text

Syntax Compared 15 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 16

Slide 16 text

Syntax Compared 16 if($morning == true){ echo “Hullo” } if ($morning) echo “Hullo” if morning? puts “Hullo” end puts “Hullo” if morning?

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Where Ruby Wins! • No semi-colons needed at end of statements • Dot is not used for concatenation • Calling methods on objects with 1 less character • @user.name and not $user->name • Curly braces are not necessary • What opening tags?

Slide 19

Slide 19 text

What I like about Ruby? • Tooling support • Testing, profiling and debugging are not an after-thought • Dependency management is easy • Easily switch between Ruby versions • Open source community / ecosystem • Problems solved by smart people 19

Slide 20

Slide 20 text

Ruby on Rails 20

Slide 21

Slide 21 text

What I like about Rails? • No need to depend on separate web server for development (build-in web server) • Command Line Interface (CLI) support and tools • rails new • Track DB schema changes (relatively) easily • "There's a Gem for that”™ 21

Slide 22

Slide 22 text

What I like about Rails? • MVP friendly • 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 • Many deployment options • PaaS - Heroku, Azure • Self host via VPS, shared hosting 22

Slide 23

Slide 23 text

23 More Ruby than PHP repositories

Slide 24

Slide 24 text

24 Engineers.SG

Slide 25

Slide 25 text

25 Upload site for Engineers.SG - Rails, Nginx, Passenger, Sidekiq

Slide 26

Slide 26 text

26 Bootcamp 2017

Slide 27

Slide 27 text

Downside • BYO web server (for static content) • Quite memory intensive • Mostly solvable by throwing machines at the problem. (i.e. more money) 27

Slide 28

Slide 28 text

Reflections • These are merely tools for building great web apps • Figure out the best tool for the job • Test, Build, Validate, Iterate • Knowledge in design patterns is important in understanding how we build apps better • Can still write 7000 line spaghetti Ruby files 28

Slide 29

Slide 29 text

Where to start? • TryRuby - http://tryruby.org • RailsGirls Guide - http://guides.railsgirls.com • Ruby On Rails Tutorial - https://www.railstutorial.org • RailsCast - http://railscasts.com (outdated, but good starting point) • Ruby Meetup - https://www.meetup.com/ruby-malaysia/ 29

Slide 30

Slide 30 text

Michael Cheng @coderkungfu
 @engineersftw