What is Ruby?
Ruby is a pure object oriented, general purpose,interpreted and server side scripting and programming language. It was created in 1993 by Yukihiro Matsumoto of Japan. Ruby was built for making programmer's work easy. Ruby has a lot of built-in function which are common in mostly all projects.
Why Ruby?
As I have told earlier that ruby has a number of features:
- Easy syntax
- Full object oriented
- Faster than PHP and Pthon ( slower than C, C++ and Java).
- Ruby on rails is most leading framework for web development.
If you are new with programming then don't worried about features discussed below. We will read them in these tutorials:
- Every function returns something.
- Classes are never closed and you can reopen them.
- Gems of ruby provide make it more featured.
Ruby is more than this but at this basic stage we can not discus them.
Prerequisites:
- Ruby installed
- One IDE installed
Install ruby:
On windows, installing softwares is easy. Install Ruby Installer and feel cool.
Linux and mac have already ruby installed. Use ruby -v command to check version. If you found that there is no ruby installed or want to install latest version of ruby then use these commands. Note I have ruby 2.2.2 installed. You may have new version. For latest version just check Ruby Site.
On Linux:
- sudo apt-get update
- sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
- cd
- git clone git://github.com/sstephenson/rbenv.git .rbenv
- echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
- echo 'eval "$(rbenv init -)"' >> ~/.bashrc
- exec $SHELL
- git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
- echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
- exec $SHELL
- git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
- rbenv install 2.2.2
- rbenv global 2.2.2
- ruby -v
On mac:
- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- brew install rbenv ruby-build
- # Add rbenv to bash so that it loads every time you open a terminal
- echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
- source ~/.bash_profile
- # Install Ruby
- rbenv install 2.2.2
- rbenv global 2.2.2
- ruby -v
Install IDE:
For all systems, I recommend Aptana Studio. It is free and featured.