This paper explores the roots of Ruby on Rails framework for Web applications development.  It examines the massive surge of interest in this framework, its capabilities, and compares it to some of the established frameworks in the market today.

Ruby on Rails also called RoR, Rails, or just Ruby is an open source framework of web frameworks written in the Ruby programming language, and is becoming one of the fastest growing web development technology to-date. To break it down, Ruby is an object-oriented programming language written in C programming language that integrates the strengths of Ada, Perl, and Smalltalk object-oriented features, and also shares the capabilities of Python, Dylan, and LISP. Yukihiro "Matz" Matsumoto, Ruby’s creator began developing it in 1993 in Japan and Ruby was made public in 1995 (6).  Matsumoto’s primary design consideration is to follow the principles of good user interface design to reduce the tedious work programmers must do to achieve their goal. That is, to make the productivity of program development simple and fun (12).

Furthermore, Ruby is a portable language that runs on many platforms but better under GNU/Linux and all other Unix variations as well as MS-DOS, Windows 9x/2000/NT BeOS, and MacOS X. Ruby finds its power through its built-in libraries that come with the standard Ruby distribution, from network access via HTTP and CGI programming, to data persistence using the DBM library. Ruby software libraries are managed by a system called RubyGems (6). Hence, Ruby code packaged in this manner is called a gem. Likewise, Ruby provides two levels of access to network services. At a low level, you can access the basic socket support in the underlying operating system, which allows you to implement clients and servers for both connection-oriented and connectionless protocols (11).

While Rails is all about infrastructure and is the creation of David Heinemeier Hansson, built from generic parts as he used Ruby to create Basecamp, the hosted Web-based project management tool from his company, 37signals (15). As a result, Ruby on Rails was born to provide a simple but efficient platform for web development using the tools and methods available to date. Like many contemporary web frameworks, Rails uses the Model-View-Controller (MVC) architecture for organizing applications. MVC is an architectural pattern in software engineering that separates the data model and user interface concerns, so that changes to the user interface do not impact the data handling, and that the data can be reorganized without changing the user interface (6).

The Rails framework is a very viable option for any type of web application such as e-commerce, content management, software collaboration, and so forth. Rails is packed with features that makes a developer more productive, with many of the following features building on one other: Unlike .NET or Java that requires a developer to write extensive pages of configurations codes, Rails requires simple configuration, thus cutting such similar codes down tremendously. Rails also automatically creates much of the scaffolding, which is a temporary code in the early stages of development to help get an application up quickly and see how major components work together (13). In addition, Rails’ built-in testing and support codes, known as fixtures and harnesses, make automated test cases much easier to write and run, thus allowing Ruby to execute all automated tests using the rake utility. In addition, the default environments: development, testing, and production make the overall software development cycle easier because each time a test is run, a fresh copy of the test base is created (6).

Further, Ruby and Rails is dynamically typed and runs in a source-code interpreter, and it conveniently supports metaprogramming as well as the procedural and functional paradigms, and Rails uses this capability well (8). Metaprogramming framework eliminates the need for extensive code generation and scripting, thus allowing a developer to create random templates/models, database schemas, column definitions etc… and plug them in existing components or generators. This process is useful when building relational databases, Rails’ Active Record automatically adds to your objects an attribute for every column in your database. Its dynamic code generation, “ an ability to build things based on information that does not exist until runtime,” is quite impressive and this helps to eliminate some of the headaches of code debugging (12).

Rails’ Active Record framework is a feature that saves objects to the database. Instead of the mapping strategy like in Java, Rails’ Active Record feature uses a wrapping strategy. Hence, as developers develop a relational database, it wraps each table with an Active Record class. Each instance of the class represents a row of the database. The framework then automatically discovers columns from the database table, and dynamically adds them to the Active Record class. Using Active Record, you can build a simple mapping to a typical table in two lines of code (13).

The Rails implementation of Active Record uses a secret sauce composed of three revolutionary ideas: convention over configuration, metaprogramming, and language for mapping, which is used to specify relationships between your tables (6, 1) The main advantages of using Active record framework within Rails is that as Rails adds attributes automatically based on the columns in the database, developers do not have to specify attributes in more than one place; Rails adds relationship management and validation through a custom internal language, allowing developers to declare relationships and model-based validation to be managed by the framework without relying on code generation; and the Rails’ naming conventions let the database discover specific fields, therefore developers do not need to configure primary and foreign keys because Active Record discovers them automatically (13).

The Rails infrastructure works well with a variety of web servers and databases. For example, Rails comes with its free in-built but also easy to use WEBrick server that can make direct calls to your Rails application because they are both written in Ruby. This eliminates that problem of integrating different components from different vendors. However, WEBrick web server is only suitable for development and not for production. In addition, Rails also supports other web servers such as Apache, Mongrel or LightTPD that run either FastCGI or SCGI protocols. The most widely used Rails’ web server in the world today is Apache, because of its flexibility and scalability to support different programming languages, load balancers, sprayers, and caching plug-ins (13).

LightTPD web server is second in choice because of it is light weight, built primarily for speed, and supports applications through FastCGI, SCGI or CGI application interfaces (3). FastCGI (Fast Common Gateway Interface) and SCGI (Simple Common Gateway Interface) are independent but scalable application interfaces that are open extensions to CGI (Common Gateway Interface), to provide high performance without the limitations of server specific application programming interfaces (APIs) (2).

And lastly, Mongrel is a fairly new web server that is written in Ruby with a C-component and it combines the capability and scalability of WEBrick, with some features of Apache, and the speed of LightTPD. This makes Mongrel a fast server and HTTP library that is suitable for hosting Ruby plain HTTP web applications (4).

And for databases, Rails supports MySQL, Firebird, SQLite, DB2, SQL Server, Oracle, PostgreSQL, and so forth (6). Examples of Web Hosting Services that support Ruby on Rails are “AVLUX Hosting” that provides Ruby-gems on request, Mongrel or FastCGI / LightTPD configurations for Rails, while “Openminds Hosting,” a Belgian web hosting provider offers Ruby with either Mongrel or lighttpd, PHP4/5 as FastCGI, RubyGems, SSH access, and MySQL, among other services,  “Xentra” offers Railshosting in FastCGI mode under Lighttpd in combination with MySQL on a FreeBSD platform, tuned for optimal perfomance. Good indepth support (6).

Ruby On Rails performance is based on freely available benchmarks. However, if you want high performance for Ruby On Rails, the combination of Linux, Mongrel, Apache, and Ajax is a very good option because not only is it easy to maintain but also provides better scalability.  For other performance related issues like in gaming industry, some programmers are trying to substitute C or Java codes for Ruby codes or vice versa.

Ruby on Rails has a multitude of tools for validating form data, sending and receiving email, formatting date and time, managing sessions and cookies, and building interactive functions into web pages using AJAX, an acronym for Asynchronous Javascript and XML is a term that describes using a combination of Javascript, the Document Object Model and XML technologies to assemble page content in a browser from remote servers (12). Since Ajax is asynchronous, JavaScript libraries can communicate with the server at any time, and the web page need not be frozen while waiting for a response. Ajax uses Java-Script on the browser, any language on the server, and XML to specify messages (5). Rails uses the Prototype and script.aculo.us JavaScript libraries to implement browser support for Ajax. Ajax is one of the most important emerging trends in web applications. Web sites like Google Maps and Gmail dramatically demonstrate that web applications do not have to be slow, page-at-a-time web forms. Ajax techniques can reclaim some of the fluidity and responsiveness that was lost when we moved from desktop applications to web applications (13).

Unlike many open source projects, Rails has excellent documentation. The Ruby on Rails website referenced below is one complete source for tutorials, reviews, overviews, movies, API document for the latest version of Ruby on Rails and free software download. Ruby comes with a utility called RubyDoc that generates documentation from source code and comments that you provide within the source code (14). When you install a gem, it also installs the documentation for the gem.

Although Ruby on Rails framework is still young compared to other frameworks, its capability is impressive, and it potential is unimaginable.  It combines the best of many programming languages and takes productivity to new heights. Its followers are growing and already making Java programmers envious. However, it still has along way to go. It has to address its slow performance problem, MySQL connection problems, and upgrade its compiler from being a Unicode compiler to bytecode compiler like Java to improve its compiling speed.

References:
1. Ajax on Rails
By Curt Hibbs
06/09/2005
Retrieved on February 23, 2007
http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html

2. FastCGI
Retrieved on February 21, 2007 from http://en.wikipedia.org/wiki/FastCGI

3. Lighttpd:
Retrieved on February 22, 2007 from www.lighttpd.net

4. Mongrel: Faster is Possible
Retrieved on February 22, 2007 from  mongrel.rubyforge.org

5. Prototype: Easing AJAX's Pain
By Bruce Perry
April 05, 2006
Retrieved on February 24, 2007
http://www.xml.com/pub/a/2006/04/05/prototype-javascript-ajax.html

6. The Rails API: Welcome to Rails
Retrieved on February 20, 2007 from
http://api.rubyonrails.org/
http://api.rubyonrails.com.

7. Ruby on Rails: RailsWebHosts
Retrieved on February 22, 2007 from http://wiki.rubyonrails.com/rails/pages/RailsWebHosts

8. Ruby for the Java world
By Joshua Fox, JavaWorld.com, 07/17/06
Retrieved on February 21, 2007 from
http://www.javaworld.com/javaworld/jw-07-2006/jw-0717-ruby.html

9. Ruby on Rails Development
Retrieved on February 21, 2007 from http://www.answers.com/topic/ruby-on-rails

10. Simple Common Gateway Interface (SCGI) protocol
Retrieved on February 21, 2007 from http://en.wikipedia.org/wiki/SCGI

11. Programming Ruby: The Pragmatic Programmer's Guide
Retrieved on February 24, 2007 from http://www.rubycentral.com/book/lib_windows.html

12. What is Ruby on Rails?
Retrieved on February 22, 2007
http://www.thewhir.com/find/web-hosts/articles/What_is_Ruby_on_Rails.cfm


13. Ruby on Rails and Running: Lightening-Fast Web Development.
Retrieved on February 21, 2007 from http://www.oreilly.com

14. Ruby documentation: Help and documentation for the Ruby programming language.
Retrieved on February 20, 2007 from http://ruby-doc.org/

15. Ruby on Rails: An Interview with David Heinemeier Hansson
By Edd Dumbill
08/30/2005
Retrieved on February 23, 2007
http://www.oreillynet.com/pub/a/network/2005/08/30/ruby-rails-david-heinemeier-hansson.html