Rails Vs CakePHP

Post on 06-May-2015

12.208 views 0 download

description

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

Transcript of Rails Vs CakePHP

PHP Vs RubyCakePHP Vs Ruby On Rails

Gautam Rege

A brief debate between PHP and Ruby, CakePHP and Rails

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

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! ;)

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 !

Ruby On Rails - Overview

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

Object Caching Query Caching Fragment Caching

What do we discuss now?

PHP Vs Ruby

CakePHP Vs Rails

What is Ruby and Ruby On Rails?

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

TIOBE Programing Community Index – Jan 2010

Relative Language Popularity over 5, 10, 25 years

Programing Community Index

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?

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 Objects@user.first_name

Relationshipsbelongs_to

has_many

has_one

has_many :through => …

meta-programing

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

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

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)

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

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.

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

Ruby On Rails

I hereby promise that we shall develop

the blog application

WITHOUT TYPING A SINGLE LINE OF CODE

in

1 MINUTE.

Steps

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

Steps

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

Steps

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

Steps

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

Steps

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

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

Satisfied NOW??

No? Alright! Now you are becoming a programmer!

Lets add some UI styles to make it look better

Some more 'coding' here!

Thank You!

- Shoot me?

(with questions only please)