Ruby on Rails - Making Web Development Fast and Fun
Ruby on Rails is a breakthrough in the web development arena. "Powerful web applications that formerly might have taken weeks or months to develop can be produced in a matter of days," says Tim O'Reilly, Founder of O'Reilly Media. Ruby on Rails has the capability to handle large traffic volumes for large enterprises. RoR evangelists vouch for Ruby on Rails in terms of the web development time, compactness, rapid deployment capability, database portability, scalability and readable code generation compared to other languages. Despite few glitches, RoR is being advocated in the web development community and is expected to become a dominant web development platform among web developers in the coming years. This article thoroughly scans the RoR framework; finds loopholes in it; balances them and tries to exhibit its capabilities to web developers and large enterprises.
What is Ruby on Rails?
RoR can run on any web server that implements CGI or FastCGI. RoR includes WEBrick, a simple Ruby web server that is distributed with Ruby. It supports database like MySQL, PostgreSQL, Oracle, DB2, SQL Server, SQLite, etc.
MVC Architecture: Ruby on Rails is based on Model View Controller architecture pattern that isolates the database from other components of the application, permitting independent development, testing and maintenance of each component.
Scaffolding: One of the attractions of Rails is its scaffolding. Rails can automatically construct some of the models and views needed for a basic website. The programmer may also run an external command to generate Ruby code for the scaffold in advance.
Convention over Configuration (CoC): Another important characteristic of Rails framework is convention over configuration (CoC). If the developer follows suggested naming conventions, Rails does not need much configuration. It is only when your behavior deviates from the implemented convention, then you configure your desired behavior. Rails framework lets you write beautiful code by favoring convention over configuration. This leads to less codification.
Don Not Repeat Yourself (DRY): Rails framework is based on the rapid development principle called Do Not Repeat Yourself (DRY). Using the ActiveRecord module of Rails, the developer does not need to specify database column names in class definitions. Instead, Rails can retrieve this information from the database based on the class name. This leads to less repetition of information.
REST Design Pattern: Rails supports REST design pattern for web services. The REST architectural style is based around client-server relationship. Browsers request pages from Rails by making a request for a URL using a specific HTTP method, such as GET, POST, PUT and DELETE. Each method is a request to perform an operation on the resource. A resource route maps a number of related requests to actions in a single controller.
Extensive AJAX Library: Ruby on Rails is also noteworthy for its extensive library of Ajax functions. Rails helper methods can be used to call Ajax functions.
Integrated Test Environment: Automated testing is an underlying philosophy of Rails. RoR framework embraces test-driven development. It comes with an automated test functionality that automatically creates test files for mock object testing. Hence, extensive number of functional and integration testing can be performed to identify existing problems in the early stages of development.
SEO-friendly URLs: Clean URLs are very important for search engines. Rails framework creates custom or search engine friendly (SEO) URLs.
Library of Database and Components: RoR introduces the ActiveRecord framework, which is an ORM layer. ActiveRecord automatically maps tables to classes, rows to objects and columns to object attributes. It automatically determines the attributes of a model in the table at runtime. Components can be used to store reusable code.
Agile in Nature: RoR supports agile methodology for development and helps developers create web products quickly. Web applications that take months to develop on other frameworks can be done on RoR framework in a matter of weeks.
Pros and Cons of Ruby on Rails
While RoR platform is gaining acceptance among web developers, it has not yet seen the popularity of Java or .NET based frameworks, which have been around for many years. Critics observe the following loopholes in RoR framework:
Scalability: Critics have questioned the scalability of RoR framework. They often mention various Twitter outages in 2007 and 2008, which spurred Twitter's partial transition to Scala for their queuing system and other middleware. The user interface aspects of the site continue to run Ruby on Rails.
Flexibility: Rails does not suit every web project or product. It is not the best bet for simple website development. It is the right platform for a primarily database-driven web application.
Incompatibility: Rails' structured and organized approach can be its strength as well as weakness in terms of flexibility and compatibility. Rails framework is only effective if you follow the conventions. It can make a developer or programmer restrictive.
Development Speed: RoR has the wealth of pre-written code and many popular components like ORM, JSON, Web Services and other APIs built-in. The developer often creates code in the early stages of development to test the compatibility of various applications and major components. Rails framework automatically creates much of the scaffolding and reduces development time and effort significantly.
Less Code and Less Repetition: C-o-C and DRY principle lead to less coding and less repetition. Most of Java and .NET based frameworks compel you to write pages of code. If a developer follows conventions in RoR, he does not need much configuration. Generally, it saves substantial amount of time and cost.
Increased Productivity: Built-in Scaffolding, Don't Repeat Yourself (DRY), Rails Conventions and Agile methodology help developers develop web applications quickly. Less code and less repetition results in fewer mistakes and therefore increases productivity.
Good Documentation: Ruby code is very readable and therefore is self-documenting. There is no need to write separate documentation if other developers pick up the project.
Beauty of Ruby Language: The appeal of RoR platform lies in the elegance and directness of the Ruby language. Ruby is one of the best languages for meta-programming. It combines Smalltalk's elegance, Python's ease of use and Perl's pragmatism.
Who is on Rails?
Now, RoR is being used for a wide range of dynamic web projects around the world. It is not limited to the small-scale web projects and many big names in the world of Internet have implemented RoR into sections of their web applications. Here is a short overview of the most prolific ones: Basecamp, Twitter, Yellow Pages, Penny Arcade, Campfire, Hulu, Groupon, Shopify, Scribd, 43places, 43people, Urban Baby, Xing Marketplace, Pragmatic Bookshelf, Odeo, Zendesk, Iconbuffet, Get Satisfaction, iLike, Justin TV.
Ruby on Rails framework is optimized for developer happiness and increased productivity. It encompasses all the best practices followed by other technologies. It accelerates web development process from the very outset. RoR developers worldwide are experiencing huge benefits in terms of development time and maintenance cost. Most have reported 40-50% reduction in development time on their web development projects using RoR. It is being advocated in the web development community for its web development speed and amazing productivity. Undoubtedly, Rails is the best bet for a dynamic and primarily database-driven application.