Tools to begin mining in Ruby
After we install Ruby, the next thing is to prepare our development environment.
As .net developers we are used to having a robust IDE.
Visual Studio is a powerful IDE that helps us in our day to day code. But, there are any Ruby IDE?
Thankfully yes. We can use RubyMine from Jetbrains.
Ruby Mine is a powerful IDE. Runs on Windows, Linux and Mac and also have an integrated debugger. You can download RubyMine at http://www.jetbrains.com/ruby/
We also have Aptana Studio, and you can download it at http://www.aptana.com/
But if you don’t want to use any IDE, you can choose your preferred text editor, like notepad++ or sublime text or vim.
Much likely, you will find some plugin to help you with Ruby.
I’m learning with RubyMine and if you are familiarized with Jetbrains products, like Pycharm, IntelliJ or WebStorm you will feel comfortable with RubyMine.
Great, but there’s something I want to show before we go to our IDE, and that is the IRB.
The IRB is an interactive shell where we can play with Ruby. It’s an REPL (REPL stands for read, eval, print, loop). Lisp where one of the first to show us the REPL.
Static Vs Dynamic
Let’s open our REPL.
First open the cmd and type IRB, and now we are inside our IRB.
Let’s begin by getting closer to variables.
In Ruby, you don’t need to declare a variable you just create it the time you need.
If you came from C# or Java, the first difference you will note in Ruby is that it’s dynamically typed. If we get the variable, we just assigned an integer and declared a string you will see Ruby doesn’t complain.
In fact, let’s see our variable type before we change. To see the type just call my variable.class
Now let’s assign a string and see the type again
But what’s the difference between statically typed to dynamically typed?
A language is statically typed if the type of a variable is known at compile time.
A language is dynamically typed if the type of a variable is interpreted at runtime
The main advantage of a statically typed is that the compiler can do all kinds of checking. While in dynamic typed you can write a little quicker.
IMHO, dynamic typed languages also force you to write more tests (which is good), so that you don’t have a lot of bugs.
What did we learn today?
In Ruby, we do have IDEs, but if you don’t want to use one you can still use your favorite text editor.
IRB is a great way to begin familiarize with Ruby, and as we saw, Ruby is dynamically typed.
We also saw a brief of the difference between statically and dynamically typed languages.
And that’s it, next we will see if Ruby is strong or weakly typed.