Ruby on Rails ("Rails") is the dominant web programming framework for Ruby and, even outside the
Ruby community, is considered the epitome of the latest generation of high-productivity, open source
web development tools. Django is one of many competing web development frameworks for Python. It
is notable, first, for being highly regarded amongst Python programmers, and second, for being one of
the few of the new generation of frameworks that does not ape Ruby on Rails. Both Rails and Django
claim greatly enhanced productivity, compared with more traditional web development frameworks.
In this paper, we compare the two frameworks from the point of view of a developer attempting to
choose one of the two frameworks for a new project.
Driving Behavioral Change for Information Management through Data-Driven Gree...
Rails vs Django Study Presentation
1. A Rails/Django Comparison
by Ben Askins and Alan Green
This work is licensed under the Creative
Commons Attribution-NonCommercial-
ShareAlike 2.5 License. To view a copy of this
license, visit
http://creativecommons.org/licenses/by-nc-sa/2.5/
or send a letter to Creative Commons, 543
Howard Street, 5th Floor, San Francisco,
California, 94105, USA.
The original version of this presentation is
available at http://3columns.net/habitual/docs/Pres2.odp
12. Development environments different: This was just a single trial. Really need:
● New Mac vs Old Windows laptop ● Multiple developers
● Central Coast vs Cityrail ● Multiple applications
● Multiple environments
“Multiple” means “statistically significant”
Developer skill level:
● Not identical
● Too advanced to be called ‘beginners’
● Insufficiently advanced to be ‘typical’
Didn’t consider:
● Performance
● Deployment
● Maintainability
LOC and time-to-implement ● Enterprise-friendliness
measurements are stupid:
● Not transferable to other developers
● Only rough indicator of complexity Unrepresentative example application:
● Too few pages
● No Atom/RSS feeds
● No public data entry
Development practices:
● Didn’t do it the “best way”
● Older versions of Rails and Django
● Didn’t use this or that helpful third party feature
Part-time development – start-stop effect and gaps between sessions
27. Hours to Implement
30.00
25.00
Models
Project set up
20.00 Develop Test data
HTML Prototype
15.00
10.00
5.00
0.00
Rails Django
28. Hours to Implement
30.00
25.00
Home page
Models
20.00 Project set up
Develop Test data
HTML Prototype
15.00
10.00
5.00
0.00
Rails Django
29. Hours to Implement
30.00
25.00
Basic pages
Home page
20.00 Models
Project set up
Develop Test data
15.00 HTML Prototype
10.00
5.00
0.00
Rails Django
30. Hours to Implement
30.00
25.00
Admin pages
Basic pages
20.00 Home page
Models
Project set up
15.00 Develop Test data
HTML Prototype
10.00
5.00
0.00
Rails Django
31. Hours to Implement
30.00
25.00
Amazon interface
Admin pages
20.00 Basic pages
Home page
Models
15.00 Project set up
Develop Test data
HTML Prototype
10.00
5.00
0.00
Rails Django
32. Hours to Implement
30.00
25.00
Data loading code
Amazon interface
20.00 Admin pages
Basic pages
Home page
15.00 Models
Project set up
Develop Test data
10.00 HTML Prototype
5.00
0.00
Rails Django
33. Hours to Implement
30.00
25.00
Test, tidy
Data loading code
20.00 Amazon interface
Admin pages
Basic pages
15.00 Home page
Models
Project set up
10.00 Develop Test data
HTML Prototype
5.00
0.00
Rails Django
34. Hours to Implement
30.00
26:46
25.00
Test, tidy
Data loading code
20.00 Amazon interface
Admin pages
16:36 Basic pages
15.00 Home page
Models
Project set up
10.00 Develop Test data
HTML Prototype
5.00
0.00
Rails Django
35. Hours to Implement
30.00
26:46
25.00 Admin Pages
Test, tidy
Data loading code
20.00 Amazon interface
Admin pages
16:36 Basic pages
15.00 Home page
Models
Project set up
10.00 Develop Test data
HTML Prototype
5.00
0.00
Rails Django
36. Hours to Implement - without Admin
30.00
25.00
Test, tidy
Data loading code
20.00 Amazon interface
18:21 Basic pages
Home page
15:39
15.00 Models
Project set up
Develop Test data
10.00 HTML Prototype
5.00
0.00
Rails Django
40. Lines of Code
800
700
600 YAML data loading
View/Controller
500 Model
400
300
200
100
0
Rails Django
41. # Reader test data
Ben:
id: 1
username: benj72
fullname: Ben Askins
bio: Eats books for breakfast
Alan:
id: 2
username: agreen
fullname: Alan Green
bio: Fond of snakes
Fred:
id: 3
username: fred
fullname: Fred Wilkins
bio: Loves a good romantic thriller
readers.yml
42. Lines of Code
800
700
600 YAML data loading
View/Controller
500 Model
400
300
200
100
0
Rails Django
43. Lines of Code
800
700
600 Authentication
YAML data loading
500 View/Controller
Model
400
300
200
100
0
Rails Django
44. Lines of Code
800
700
600 Schema Migration
Authentication
500 YAML data loading
View/Controller
400 Model
300
200
100
0
Rails Django
45. Lines of Code
800
700
600 HTML Helpers/
Template tags
500 Schema Migration
Authentication
400 YAML data loading
View/Controller
Model
300
200
100
0
Rails Django
46. Lines of Code
800
700
600 Templates
HTML Helpers/
500 Template tags
Schema Migration
400 Authentication
YAML data loading
View/Controller
300
Model
200
100
0
Rails Django
57. class CreateReadings < ActiveRecord::Migration
def self.up
create_table :readings do |t|
t.column "book_id", :integer
t.column "reader_id", :integer
t.column "date_read", :datetime
t.column "reading_time", :integer
t.column "notes", :text
end
end
def self.down
drop_table :readings
end
end
Schema is Versioned
58. ● Drop database tables
● Re-create tables
manage.py syncdb
python yaml/load_data.py
● In production, you write migration DDL by hand
Django DB evolution
59. Browser Browser
Web Server Web Server
Routes View urls.py Template
Controller View
Model Model
Rails Django
Database Database
64. ● Can save a lot of time
● Good looking result
● Does simple CRUD quite well
but...
● Only does simple CRUD
● Only does simple relationships
● Security not fine-grained
● Not intended for public-facing pages
Django Admin application
68. ● Began Oct 2003 ● Began Fall 2003
● DHH ● Adrian and Simon
– in reaction to PHP – “ditched” PHP
● Extracted from ● Extracted from
Basecamp ljworld.com
● Released: July 2004 ● Released: July 2005
● 1.0 shipped Dec 2005 ● 1.0 not yet shipped
– Latest is 1.1.6 – Latest is 0.95
History
93. ● Photos
– Sad puppy:
http://www.flickr.com/photos/sookie/108356632/
● Software
– David A. Wheeler’s Sloccount
● http://www.dwheeler.com/sloccount/
– HTML Template by Andreas Viklund
● All of the paper reviewers
● Our bosses:
– Cirrus Technologies
– Karen Askins
With thanks to
94. ● “The Builders of Basecamp”
– http://www.oreillynet.com/pub/a/network/2005/03/10/base
● Snakes and Rubies presentation
– http://video.google.com/videoplay?docid=2939556954580
● Django FAQ
– http://www.djangoproject.com/documentation/faq/
95. Lots of interest in these two frameworks
Similar in some ways
Different in others
How to choose between them?
Why Comparing?
99. def standard_view(request, queryset, template_name,
template_object_name, **extra_context):
""" Wrapper around the object_list generic view.
"""
return object_list(request,
queryset=queryset,
allow_empty=True,
template_name=template_name,
template_object_name=template_object_name,
page=get_page(request),
paginate_by=PAGE_SIZE,
extra_context=extra_context)
def get_page(request):
""" Determines the current page number.
"""
return int(request.GET.get('page', 1))
standard_view
100. Hours to Implement
30.00
20:40
25.00
Test, tidy
Data loading code
20.00 Amazon interface
Admin pages
10:30 Basic pages
15.00 Home page
Models
Project set up
10.00 Develop Test data
HTML Prototype
5.00
0.00
Rails Django