Getting Started with Ruby on Rails

ruby on railsRuby on rails, or commonly refereed as “rails” is web-based application framework that runs on ruby programming language. It is available as an open source tool, which means its accessible on free-licensing via the web. As the name suggests, ruby on rails has two aspects to it, the ‘ruby” which is a modern programming language (an object oriented language)and the “rails”or“ruby on rails” which is the framework that uses ruby language to build web applications. Ruby on rails is fairly popular and considered more flexible than all programming languages. From this simple definition it is safe to assume it is easier to find a ruby on rails developer than a Perl, PHP or Java developer.

In order to understand the rails framework (ruby on rails) it is important to know a few concepts about Ruby the programming language.

So what is Ruby?

Ruby is a regular general purpose programming language which can be used in standalone applications, web applications, server scripts administration tasks etc. Ruby was built in the mid-nineties by Yukihiro Matsumoto or “Matz” as he is commonly called. Just like Perl, Python and others it is an an object-oriented language.

Ruby on rails has been accredited to making the programming language “ruby” popular,but there is good chance that by choosing ruby, the authors of “ruby on rails” vindicated “ruby” its a chicken and egg story.

The following reasons will help us understand why the authors of rails, chose ruby and these same reasons will lay ground for our understanding of the rails Framework.

Object-Oriented- It means that in this language like a few other languages, objects form the building blocks of the program. Data and its behaviors is encapsulated in this objects and that’s essentially what forms the applications.

It is a dynamic language, which means one can assign any data object variable without having to indicate if its a integer or string. Its classes and objects are also dynamic which means methods can be modified or created during execution (metaprogramming), lastly it is interpreted as it runs, there is no compilation step. It is stored as a source code.

In ruby, all operators are classified as objects. It’s flexibility and openness gives the programmer an ability to change methods and variables at any point of runtime. The changing variables and methods from classes, objects, and even core classes like integers and strings make the language highly dynamic.

Ruby’s Syntax is very simple, it has no special characters as other languages do. ruby developers are free to use semicolons at end of sentences but that is only if they choose to. Braces are used, but just for aesthetic reasons, every block is framed by two magic words “do” and “end” everything is is simple and clear. Ruby makes use of special characters to develop its “variable declarations” and define their scope. Variables can be local or constant, and they are differentiated as follows; Local variables start with lowercase letter while constant variables start with uppercase letter.

Loops like “for” and “while” are hardly used, instead ruby uses iterators that a programmer can pass blocks to. In this language everything is executed for every element in the collection. Blocks are built to have access to the surrounding scope and that refers to the scope that in ruby everything is an object.

Just like other programming languages Ruby has conditionals, and it is important to note these two exceptions. a). Putting the condition after the statement the condition is meant to protect is OK, to enhance readability. b) Ruby has an “if “and also an “unless”

Symbols: In Ruby, symbols are a special feature that would act like ENUM would act in C language. They are meant to be parameters and, or pointers to methods and variables.

Classes and modules; although ruby supports single inheritance only developers can use a feature called mixins to extend functionality and class very easily.

There are other qualities to Ruby, but the above features must have formed the core reasons why the Ruby on Rails developer Melbourne choose this language.

So what is Ruby on Rails?

Rails was created by Heinemeier Hansson. Originally built for building a personal project, it ended up being extracted and offered as a license-free framework in 2004. Since then there are developers working continuously to improve the framework and make it a better web app tool. If you think of rails, or ruby on rails, think of tracks. They create a path with which, ruby the language is used, or transformed to develop web application faster and better.

Ruby on rails is built on the Model-View-Control design, which essentially breaks your application into three: Model-View-Control.This approach makes it easier to build and maintain applications. Although Model-View-Controller approach is something applicable to other application language, in rails it is built-in while in other languages, a developer has to manually improvise to keep up with the approach. This inherent quality is what makes rails a natural and easy tool.

While building web applications using rails can be slower and might face challenges with scalability, it focuses on a unique way of increasing developers productivity and not performance. The focus of convention over configuration. The challenges provided by its scalability are slowly being overcome by continuous updates to the program

From the above “convention over configuration” aspect ruby on rails developer do not have to focus on structuring everything and how they would like database objects structured, Instead, ruby on rails has inbuilt structures that present expert opinions on how web applications should be. The developers might have to take some time learning the build around these structures but once they figure out the rails way of doing things, then they save so much time. The rails, or the built-in structure gives ruby on rails the name; “opinionated software” It already has pre-conceived structure on how web applications are supposed to be structure and everything built within the tool points towards the pre-conceived opinion. There is a room for wiggle but a tide one.

The other important feature is that rails is built for creating web applications that use or access database. While using an objected-oriented language to access objects in a database requires a programmer to write codes defining object relationships in the database. Rails make it easier in that, there is an built-in tool that maps all possible object relationships. This greatly simplifies the coding. The object relationship mapper, in rails is refereed to as ActiveRecord. All database communication is channeled through ActiveRecord, the programmer only creates the database, the relationship mapper looks at every object and maps out every possible relationship.

The ActiveRecord is reinforced by another important aspect rails is the ActiveSupport module. This simplifies the coding by providing helpers specifically built for creating web applications. It is this aspect that qualifies rails as a language specifically designed for web application framework.

Rails also has the module that helps uses render views. This is looking at webpage layout, also called a templating system. It is also possible to intermix HTML and ruby code, using a feature called Embedded Ruby (ERB). In viewing the layouts, users can use the “partial” option, where web page views could contain only one part, and together these parts could be combined to form a whole webpage. In addition a developer can use one partial for several projects, a style refereed to as : partial for arrays; where the partial is allocated to several elements in the array. Rails utilizes helpers, to produce forms and popular HTML elements. It also has inherent support for JavaScript frameworks, and this make it easier translating code into Java or related codes.

Why would one choose to become a Ruby on Rails developer?

Building web applications using Ruby on Rails is fun, faster and natural. This means that, for developers who have been working with Python, PHP, Java or .net will larn a whole new way, but the learning time will be compensated by quicker code production. They will have to learn a new approach to coding, yet their efforts will pay-off once they are fluent in using rails. The development process is more natural, flexible, and more rewarding.
The bottom line is rails is not a perfect framework. It has faced criticism with speed for the simple reason that computing is not its forte. Rails is not for web applications that need to perform computing. The underlying reason is the path used in processing url requests from web application built on rails have to go through a longer path, than web applications built on languages like Java or PHP. To help speed such web applications deployed on rails might require more server capacity to make up for slow processing.

In today’s Software Development practices, the Agile approach is in high demand. Building applications in incremental iterations is on the rise, and there is no better way to build web applications better than by using a tool that was already tailored for incremental coding: ruby on rails.