Rails Vs CakePHP

27
PHP Vs Ruby CakePHP Vs Ruby On Rails Gautam Rege A brief debate between PHP and Ruby, CakePHP and Rails

description

A brief debate on PHP Vs Ruby and CakePHP Vs Ruby On Rails.

Transcript of Rails Vs CakePHP

Page 1: Rails Vs CakePHP

PHP Vs RubyCakePHP Vs Ruby On Rails

Gautam Rege

A brief debate between PHP and Ruby, CakePHP and Rails

Page 2: Rails Vs CakePHP

About Me

Gautam Rege Director @ Josh Software Pvt. Ltd. 9+ years software experience. Rubyist & Entrepreneur @gautamrege http://gautamrege.wordpress.com

Josh Software Ruby On Rails, Ruby On Rails, Ruby On Rails Little bit of J2EE and .NET

Page 3: Rails Vs CakePHP

Am I out of place??

What will you gain by listening in on the debate between 2 RAD frameworks?

Is this about Rails propaganda?

Do you have rotten tomatoes to throw? Don't throw shoes and make me famous! ;)

Page 4: Rails Vs CakePHP

Ruby – Overview

Object Oriented Scripting language. Classes, Objects, instance methods etc. Blocks (yield) Simple 'Duck Typing' using 'responds_to' Mixins

Simplicity of single inheritance Power of multiple inhertitance

Meta-programming !

Page 5: Rails Vs CakePHP

Ruby On Rails - Overview

Framework built in Ruby (obviously) MVC pattern RESTful ORM using ActiveRecord Inbuilt Caching

Object Caching Query Caching Fragment Caching

Page 6: Rails Vs CakePHP

What do we discuss now?

PHP Vs Ruby

CakePHP Vs Rails

What is Ruby and Ruby On Rails?

Page 7: Rails Vs CakePHP

PHP Vs Ruby

Patched Obj. Oriented ?? Reflection & Meta-

programing ?? ?? Extremely Popular ! Tons of people

Pure Object Oriented Easy to read !! Inherent reflection &

meta-programing use Code blocks Gaining popularity Small community

Page 8: Rails Vs CakePHP

TIOBE Programing Community Index – Jan 2010

Page 9: Rails Vs CakePHP

Relative Language Popularity over 5, 10, 25 years

Page 10: Rails Vs CakePHP

Programing Community Index

Page 11: Rails Vs CakePHP

CakePHP Vs Ruby On Rails

CakePHP has been inspired by Ruby On Rails. Modeling, Routing is similar

IDEAL for PHP programmers who Do not have a choice but to use PHP Do not want to learn a new language.

Why not try the real thing?

Page 12: Rails Vs CakePHP

CakePHP Vs Ruby On Rails

AppModel Associative Arrays$user['User']['first_name']

Relationshipsbelongs_to

has_many

has_one

has_and_belongs_to_many

'on the fly' relationsbindModel

ActiveRecord Ruby [email protected]_name

Relationshipsbelongs_to

has_many

has_one

has_many :through => …

meta-programing

Page 13: Rails Vs CakePHP

CakePHP Vs Ruby On Rails

AppController AppController set() method to

access data from controller in a view.

??html

AJAX$ajax->link

ActionController ActionView Instance Variables in

controller 'magically' available in views.

responds_to? | format |html, xml, json, js

AJAXlink_to_remote

Page 14: Rails Vs CakePHP

What I found missing in CakePHPaka – Rails rocks! ;)

Migrations are missing or not not recommended. Even the tutorials do not use migrations but raw

SQL. No mention of deployment.

Guess its a standard Apache + mod_php setup. Use of associative arrays instead of objects

$user['user']['first_name'] instead of @user.first_name

Page 15: Rails Vs CakePHP

What I found missing in CakePHPaka – Rails rocks ! ;)

No support for RESTful routes

map.resources :users Provides CRUD for User model

/users ( GET | POST )/users/:id ( GET | DELETE)/users/:id/edit (PUT)

Page 16: Rails Vs CakePHP

What I found missing in CakePHPaka – Rails rocks ! ;)

There is still a lot of code visible. Lot of configuration Lot of coding / views etc. etc.

DEMONSTRATION of the Rails way ??

Page 17: Rails Vs CakePHP

Demonstration - Blog

Create a web application for blog posts. A post has a Title and some body text. A post may be published optionally.

We should be able to create a post. We should be able to edit a post. We should be able to delete a post. We should be able to list all posts. All information should be stored in database.

Page 18: Rails Vs CakePHP

Time and Effort Estimate

How much TIME would you take for this? How many LINES OF CODE would you write? Modules:

Database configuration Database Schema Logic for posts HTML design Testing

Page 19: Rails Vs CakePHP

Ruby On Rails

I hereby promise that we shall develop

the blog application

WITHOUT TYPING A SINGLE LINE OF CODE

in

1 MINUTE.

Page 20: Rails Vs CakePHP

Steps

Create a rails project Create the “post” scaffold Update the database Start the server Test it out Create a post Edit a post

Page 21: Rails Vs CakePHP

Steps

Create a rails project Create the “post” scaffold Update the database Start the server Test it out Create a post Edit a post

Page 22: Rails Vs CakePHP

Steps

Create a rails project Create the “post” scaffold Update the database Start the server Test it out Create a post Edit a post

Page 23: Rails Vs CakePHP

Steps

Create a rails project Create the “post” scaffold Update the database Start the server Test it out Create a post Edit a post

Page 24: Rails Vs CakePHP

Steps

Create a rails project Create the “post” scaffold Update the database Start the server Test it out Create a post Edit a post

Page 25: Rails Vs CakePHP

Satisfied?

Are we ever satisfied? NOW lets add some fancy stuff to this.

Lets add some validation A post cannot be created without a title.

NOW we do a little bit of coding !!

Page 26: Rails Vs CakePHP

Satisfied NOW??

No? Alright! Now you are becoming a programmer!

Lets add some UI styles to make it look better

Some more 'coding' here!

Page 27: Rails Vs CakePHP

Thank You!

- Shoot me?

(with questions only please)