CSC/ECE 517 Spring 2014/ch1a 1c yj: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 83: Line 83:


=== Weakness ===  
=== Weakness ===  
;Inability to create tables based on the definition model.
; Speed
: Although the current version is much faster and efficient than previous versions, CakePHP is still one of the slowest frameworks. It is even slower than Ruby on rails <ref="benchmark" />
;No admin interface
;No admin interface



Revision as of 02:50, 11 February 2014

Background

In such internet age, web applications had been highly valued by programmers on the Web. To help those who aimed to utilize the design patterns to produce a maintainable, readable, and high quality code, many object-oriented web frameworks has been released public that allow enthusiastic programmers to take advantage of the well-built developing environment.

You may already see several examples from other chapters(here, here, and here), but today, we are going to deliver several further details on each, based on their strength and weakness, and make a comparision to make the decision on choosing the best object-oriented web frameworks being easier. At the end of the page, a table of #Feature-based Comparison on Web Frameworks is also provided.

Frameworks

As there are tons of object-oriented web frameworks can be found online, we will need to limit only four of the most famous web frameworks we consider will be discussed today.

Ruby on Rails

  • First created: 2003 by David Heinemeier Hansson <ref>http://rubyonrails.org/</ref>
  • Current Developer: Rails Core Team
  • Current version: 4.0.2 and 3.2.16
  • Licence: Rails under the MIT license. Ruby under the Ruby License.

Ruby on Rails has been one of the most popular web app frameworks on Ruby <ref>https://www.ruby-toolbox.com/categories/web_app_frameworks</ref>, Some of the famous applications built with Rails can be Twitter and Github.

Strength

Faster development
Many people say Ruby on Rails helps developers being productive. People even developed a survey to proof such claim is true. <ref>http://martinfowler.com/articles/rubyAtThoughtWorks.html#IsRubyMoreProductive</ref> Forgoing the runtime performance, ruby comes with the interpreter and support of MVC design, that help the developer minimize any repeating code, and maximize the scalability of web application .
More readable code thanks to Ruby
It may be hard to say if this is one of the strengths of rails, because readability is the advantage for every frameworks developed on Ruby. It still worth to compare with the frameworks which are developed on languages other than Ruby.
A code in Ruby <ref>http://www.slideshare.net/dosire/when-to-use-ruby-on-rails-1308900#</ref>

 describe Bowling do
   before(:each) do
       @bowling = Bowling.new
   end
   it "should score 0 for gutter game" do
       20.times { @bowling.hit(0) }
       @bowling.score.should = 0
   end
 end

Will look like this in PHP

Class NewBowlingGame extends PHPSpec_Context
 {
  private $_bowling = null;
  public function before()
  {
       $this->_bowling = new Bowling;
  }
  public function itShouldScore0ForGutterGame()
  {
       for ($i=1; $i<=20; $i++) {
       $this->_bowling->hit(0);
       $this->spec($this->_bowling->score)->should->equal(0);
       }
  }
}

Weakness

Run relatively slow
Since Ruby on Rails designed to optimize the development speed and readability, such optimization sacrificed the runtime speed on web applications that was written in rails. In fact, according to performance comparison result published online, the performance of rails on JSON serialization, single query, multiple queries, fortunes, data updates and plain text, are way far from the top tier of all of the frameworks. <ref>http://www.techempower.com/benchmarks/</ref>
Unique way of thinking
Ruby is a smart language, so as Ruby on Rails. Most of the works on rails seems to be more than straight forward, as well as readable. However, the more people focus on rails, the more they are far from the effort behind. There are more and more frameworks that were inspired by rails, but most of the long-existed large scale works are built based on a traditional way. For most of the times, the way of thinking in Ruby on Rails is not adaptable to other languages, especially for those frameworks that are considered more "enterprise-based".

CakePHP

Inspired on the Ruby on Rails project and using many of the same concepts, it’s called this way because it was written based on a minimal version of a Rapid Application Framework in PHP. CakePHP is licensed and distributed under the MIT license, and provides an extensible architecture for development of web applications.

The slogan of CakePHP is to “CakePHP makes building web applications simpler, faster and require less code.” [2] Started from 2005, CakePHP has been praised for its security, flexibility, and the support of good MVC convention.

Strengths

Speed
Scalability
Security built-in tools
CakePHP comewith a lot of security built in. For example, it can help to parse SQL queries to prevent SQL injections, as well as allowing customize regular expressions to catch anything that the developer think may be harmful. It also comes with the [Security Component], which allows people to integrate tighter security in their web app such as

Weakness

Speed
Although the current version is much faster and efficient than previous versions, CakePHP is still one of the slowest frameworks. It is even slower than Ruby on rails <ref="benchmark" />
No admin interface

Django

This is a high level Python Web framework for rapid development on the Web in an easy way. It mainly focus on the DRY (Don't Repeat Yourself) Principle, and it provides several free API’s to handle database-abstraction. According to the documentation, a typical workflow is to get the site as fast as possible, populate the data (as in a content management publishing), to finally develop the data in the same way is presented to the public.

Strength

Just to mention some of the most important:

With the Object-relational it is possible to define the data model entirely in Python and get a rich dynamic database-access API for free — but you can still write SQL if needed.

Quick example This example model defines a Person, which has a first_name and last_name:

from django.db import models

class Person(models.Model):

   first_name = models.CharField(max_length=30)
   last_name = models.CharField(max_length=30)

first_name and last_name are fields of the model. Each field is specified as a class attribute, and each attribute maps to a database column.

The above Person model would create a database table like this:

CREATE TABLE myapp_person (

   "id" serial NOT NULL PRIMARY KEY,
   "first_name" varchar(30) NOT NULL,
   "last_name" varchar(30) NOT NULL

);


The Admin interface save work on creating interfaces for people to add and update content.

The Cache system based on memcached enables django the super perfomance needed for any application.

Weakness

Terminology. Apparently Django does not share the same view for the MVC framework, the Controller is called “View” and the View is called “template”

Some would say that is not great customizable, which could be good for a rapid development, but it will limit the flexibity too.

Play!

Written in Scala and Java, Play Framework is another choice for Java lovers that was developed based on open source, following the MVC model pattern, and is also inspired on Ruby on Rails and Django. Famous websites built with Play! are LinkedIn, coursera, etc. Play! call itself as “The High Velocity Web Framework For Java and Scala” <ref>http://www.playframework.com/</ref>.

Strength

Simplified development cycle due to full-stack
play framework comes with almost everything that a web application will need for development, which minimize the waste of time on setup for the framework and looking for additional libraries during the development cycle. It comes with compiler, web server, in-memory DB server, offline documentation, integrated database manager, local and distributed cache management, fixtures, evolutions, dependency management, lots of utility libraries, unit tests, selenium tests, functional tests, and great IDE support (because it's Java!).
Provide built-in frameworks for unit testing and functional testing. Allow use to mock a whole application for testing reason
As every Java lovers got used to, play utilizes JUnit for unit testing and functional testing. Play is also famous for its unique way that approaches testing. It makes use of JavaTest with FakeAplication to allow developer to spin up a real version of "fake application" with an in-memory database. Moreover, it has a good default for selenium test for black box testing to produce reproducible tests for use cases. They also provide a decent interface to give a overview for the written tests. <ref>http://zeroturnaround.com/rebellabs/the-2014-decision-makers-guide-to-java-web-frameworks</ref>

Weakness

Simple at first, but get complicated when trying to take full advantage <ref name="javacompare">http://zeroturnaround.com/rebellabs/the-curious-coders-java-web-frameworks-comparison-spring-mvc-grails-vaadin-gwt-wicket-play-struts-and-jsf/11/#!/</ref>
Like other frameworks, it is easy to get a simple web application built with play framework to get off the ground. Play wants to provide the whole ecosystem, which is way more than a mere framework. They provide a lot of features that are really convenient to develop a web application one in all, but in some case, it is required to research into the Scala when necessary.
Significant learning curve when integrating it with any existing build tools and environment. <ref name="javacompare" />
As mentioned above, play actually provide a well-built ecosystem, but rather than a mere framework. Swapping or migrating the existed items in the infrastructure may not be working well. Even if it is in Java, it did not take advantage of the flexibility and robustness of Java.
Lack of backward compatibility
One of the most generally accepted problem of play framework is the lack of the backward compatibility. For now, play 2.x is not compatible with play 1.x, which is also a potential concern for the web developer who want to keep the framework updated in the future.<ref>http://www.javacodegeeks.com/2013/09/the-pros-and-cons-of-play-and-grails-java-framework.html</ref>

Feature-based Comparison on Web Frameworks

Feature-based Comparison on Web Frameworks <ref>http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks</ref>
Project Language Ajax MVC framework MVC push-pull Testing framework(s) DB migration framework(s) Security framework(s) Template framework(s) Caching framework(s) Form validation framework(s) Scaffolding
Ruby on Rails Ruby Prototype, script.aculo.us, jQuery Yes (ActiveRecord, Action Pack) Push Unit Tests, Functional Tests and Integration Tests Yes Plug-in Yes Yes Yes Yes
CakePHP PHP >= 5.2 Prototype, script.aculo.us, jQuery, MooTools Yes Push Unit tests, object mocking, fixtures, code coverage, memory analysis with SimpleTest and XDebug PHPUnit (cakephp 2.0) Yes, CakePHP Schema Shell by default, and some others ACL-based Themes, layouts, views, elements Memcache, Redis, XCache, APC, File Validation, security Yes
Django Python Yes Yes Push unittest, test client, LiveServerTestCase Provided by South(http://south.aeracode.org/), Django Evolution ACL-based Django Template Language Cache Framework Django Forms API No, not by default
Play Scala/Java Yes Yes Push-pull Unit test, Functional test, Selenium Yes, similar to Ruby on Rails via Core Security module Yes Yes Server-side validation Yes

References

<references/>