Getting started with Ruby – Part 1
Before we get started with Ruby, let me first give you a brief on who I am, I am Dhruva Sagar, a software engineer having a little over 4 years of professional experience having worked in technologies in and around Java, Javascript, Adobe Flex, PHP and Ruby. I have always been fascinated by programming languages and have been eager to learn new ones and I can also code comfortably in Perl, Python & Groovy, however I haven’t worked extensively on these. Right now I am working in a startup Artha42 Innovations Private Limited and am having the best time of my life!
If you have read my previous article Knowing VS Doing you might be aware of my views on the process of learning, my own process of learning Ruby has hence been on similar lines. I had first started with Ruby on Rails even before I knew anything about Ruby, which I realized much later, isn’t a very smart thing to do. Rails is an amazing web development framework, so amazing that it feels magical (1)Almost literally! when you first get started with it. But all of that magic, although great, also deprives one from the beauty that Ruby is in many ways, since there is a whole lot of stuff happening behind the scenes.
With these series of articles, I will try to take you through the essentials of Ruby with an aim to help a programmer, go from a beginner to an intermediate stage. By saying that I want to make it clear that I expect the audience to have some basic understanding of programming constructs. However, I will make an attempt to be as clear & accurate as possible to make things understandable to all.
Getting Started #
The first step towards getting started with Ruby involve in getting your development environment ready. My choice of OS is Ubuntu, and my choice of text editor is GVim, which is essentially VIM in a separate GUI window. GVim is simply amazing, I will probably write another article on how awesome it is, including a screencast showing how to debug ruby scripts from within GVim at a later time. GVim is available on all major platforms including Windows & Mac. Although Mac users tend to use TextMate. Besides these 2, Aptana Studio (Eclipse Based IDE) is also another popular option. [Ruby Installation Instructions]http://www.ruby-lang.org/en/downloads/) details the steps that you need to go through for installing ruby on various platforms, and you should be able to get that done within no time, hopefully without much hassles.
Let me first introduce you to Ruby:
Ruby (2)Source: Ruby Programming Language is a dynamic, reflective, general purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk like features
Essentially Ruby is a highly flexible & powerful programming language that takes some of the best things from other languages like Perl, Smalltalk, Lisp, etc and brings them under one single roof. Ruby also has a highly energetic, active & open community which actively contributes in the form of libraries, etc which makes the life of the Ruby developer very easy.
Besides the interpreter the above package which you setup, ships with a few nifty utilities that will make your life much better.
- IRB – Interactive Ruby Shell: This as the name suggests is the interactive ruby shell, which allows you to input ruby code directly and interpret it line by line. This is often a great place to try out and fiddle around with libraries and classes. The highly reflective nature of Ruby makes it really easy to inspect & check objects and their structure, and more often than not IRB is a better place to test & clarify your doubts rather than the api documentation.
- Rubygems: In ruby, libraries are referred to as gems. As I mentioned earlier, the community is highly active & contributes heavily in the form of such gems. If you follow to the Rubygems website, you might notice, there are over 17000 gems! That is proof enough for how active the community is. We’ll get to the details of using gems & how gems work at a later time.
I’ll conclude this article here since it’s already become quite long, I promise to get into hardcore coding from next article onwards and you will get to see how the magic works :). Hope you liked this article, please do let me know if you have any suggestions.