Any driver in the world knows: it doesn’t matter how powerful, innovative and high-tech is your vehicle if you have no chance to try it on the good road. This small everyday situation easily shows that lots of things, concepts and activities are deeply interconnected and mutually influence each other. In digital design and development, it works the same way: there’s a huge lot of factors having an impact on the final result. Bad design will spoil well-written code as well as badly developed code can bury the most sophisticated design solutions. Every side plays its big role in the final outcome which should present a user-friendly product.
Earlier we have already given closer insights into the definition, processes and tools for web development. Today’s post is going to continue the theme presenting considerations on a particular tool for web development Ruby on Rails and reviewing its benefits as well as possible pitfalls that need to be taken into account.
Let’s start with a tiny bit of history. Ruby is dynamic, object-oriented, open source programming language with a focus on simplicity and productivity, created by Yukihiro “Matz” Matsumoto and first released in the 1990s. It powers famous websites such as the original version of Twitter, Hulu, Living Social, Basecamp etc. Many companies use Ruby in some capacity: BBW, Cisco, CNET, IBM, JP Morgan, NASA, and Yahoo. Moreover, Ruby has framework which supports high level of flexibility for developer in the process of creating code for particular aims.
“Ruby is named after the precious gemstone; it’s not an abbreviation of anything. When I started the language project, I was joking with a friend that the project must be code-named after a gemstone’s name (àla Perl). So my friend came up with «ruby». It’s a short name for a beautiful and highly valued stone. So I picked up that name, and it eventually became the official name of the language.” said Yukihiro «Matz» Matsumoto, the creator of Ruby, in his interview about the roots of the programming language.
Ruby on Rails is an open-source web application framework for the Ruby programming language optimized for programmers’ sustainable productivity. David Heinemeier Hansson extracted Ruby on Rails from his work on the project management tool Basecamp at the web application company also called Basecamp. Hansson first released Rails as open source in July 2004. Major brands like Amazon and eBay even have Rails projects.
“Rails (Ruby on Rails) was extracted from my work on Basecamp—a project collaboration tool from 37signals. So it was motivated by needs, not predictions. And I believe that’s a big part of why we’re currently enjoying such success. I didn’t try to imagine what some programmers might need for a fantasy job. I just built what I needed to get my work done with a smile.” says another interviewee David Heinemeier Hansson, the creator of Ruby on Rails.
What is Ruby on Rails?
Models. They are used to represent forms of data used by the app and contain the logic to manipulate and retrieve that data. In Rails, a model is represented as a class. These forms of data are not low-level like strings or arrays.
Views. They are the templates (typically formed of a mix HTML and Ruby code). Views are used to build up the data that users of web app see in their browsers or through other clients. They can be rendered as HTML for web browsers, XML, RSS or other formats.
Controllers. Controllers provide the logic that binds together models (their associated data) and views. They process input, call methods and deliver data to the views. In Rails, controllers contain methods known as actions that, generally, represent each action relevant to the controller, such as “show”, “delete”, “view”, etc. The framework can be used with various operating systems such as Windows, Mac OS X and Linux; various databases such as SQLite, MySQL, PostgreSQL and others; various web servers such as Apache, Nginx, etc.
Talking about operations via the platform, developers usually mention several core principles. Among the main ones, convention over configuration (CoC) should be mentioned. It means that developers don’t have to spend a lot of time configuring files in order to get setup, Rails comes with a set of conventions which help speed up development.
Another important principle of software development in Rails is don’t repeat yourself (DRY). It encourages developers not to make duplications in their code and isolate functionality in small functions or files. The principle helps to make code modular, easier to understand, read and debug. When code is duplicated, the outcome becomes more complex, making it more difficult to maintain and more vulnerable to bugs.
Ruby on Rails uses Representational State Transfer (REST) architecture that rests around the relations between the client and the server. The architecture helps to create logic around the app and code that developers find highly intuitive and functional.
Another key feature is RubyGems, a package manager that makes it easy to create and share software libraries (“gems”) extending Ruby. RubyGems provides a reliable and simple system to install “gems”. Anyone can upload them to the central RubyGems website, making the “gem” immediately available for installation by others. The RubyGems website is where developers obtain the most recent version of Rails.
Benefits and drawbacks of Rails
As well as any tool or software, Ruby on Rails has its strong sides and pitfalls that need to be considered. Let’s briefly review both aspects on the basis of various feedback from developers.
Benefits for developers on Ruby on Rails
Large Community. Generally, Rails is more than development tool, it is also the large community. The members share their works, often use the same tools, and support each other. The informal community provides a diversity of jobs, recruiters, meetups, conferences, examples of businesses building websites with Rails, and clients funding startups. It is no surprise that Rails is popular on social coding resource Github. This aspect is particularly helpful for beginners.
Variety of gems. “Gem” is the software package that contains a package Ruby app or library. Commonly it is used to extend or modify functionality in Ruby apps. Some “gems” provide command line utilities to help automate tasks and speed up developer`s work. They are all publicly available at RubyGems.
Cost-effective. The process of building functionality with Rails is fast because it has the collection of open source code available within the community and set of conventions. Ruby on Rails also runs on a free operating system and works with mostly free databases and web servers. These features provide less number of working hours, quick development process and low overall cost.
Code Quality. Rails use Ruby programming language whose code has a high level of readability. This aspect increases productivity with the lower need to write out separate documentation or comments, making it easier for other developers to pick up existing projects.
Tester’s perspective. Rails has been developed with a focus on testing and has good built-in testing frameworks.
Diversity of tools. Rails provides fantastic variety of tools that help developers to deliver more features in less time. For example, it has a standard structure for different web apps in which all the common patterns are are available for programmers.
Flexibility. It is one of the biggest pros of using Ruby on Rails. For example, Rails interacts perfectly with technologies and frameworks like AngularJS. This factor offers developers opportunity to separate layers of the app and use multiple technologies.
Potential Ruby on Rails problems and limitations
Performance. Some developers complain that Rails apps are not as fast as Java or C. The statement is generally true, but for the majority of apps, it is fast enough. Rails web app may become a little slow and bloated when it is large although a high-skilled programmer has the means to tune the performance up whenever it is necessary. There is also the option of running the app under JRuby, so it will show the same performance characteristics as Java.
Hosting Issues. Not all website hosts can support Rails. The main reason is that Rails can be more resource intensive than PHP, a fact which deters some providers. Alternatively, there is a number of hosts (Virtual Private Servers) such as Amazon EC2, EngineYard, Linode or Rackspace, which can satisfy Rails developers’ needs.
Popularity. The number of Rails developers is growing year by year as more people switch to it from other programming languages. Yet, Rails is still not as popular as Java and PHP. Probably, one of the reasons for this is that the language is relatively difficult to learn especially compared to PHP. However, one of the main differences between the Rails and others in this aspect is the big amount of open source code (“gems”) which is publicly available. “Gems” are helpful for beginners because they appreciably simplify the process of web development.
Lack of documentation. It can be hard to find good documentation for the less popular “gems” and for libraries which make heavy use of mixins. Developers often end up finding the test suite playing the role of documentation and they have to rely on it to understand the behavior of the written code. This aspect isn’t bad in its essence, as the test suite should be the most up-to-date representation of the system; however, it can still be frustrating having to dive into code, when sometimes written documentation would have been much quicker.
Let’s draw up the balance. Rails is a huge web app framework with a great number of built-in features. It can be used to create either small or large app, but it tends to use more memory and resources than the other frameworks and performance can be a bit lower. In the majority of cases, Rails apps will be composed of many tens of files and have tight structure of models, views, and controllers. Anyway, nowadays the framework is popular because it is powerful, standardized, reasonable and well-established.
Welcome to read more articles on web development