HackToHell. Powered by Blogger.

Learn Ruby easily I

Ruby is an gr8(great) language, it is simple and really easy for beginners to understand,unfortunately if you have programmed in C, C++ or Java , you will find it hard to grasp.

If you do not have Ruby , get it from rubyinstaller.org.


Ruby is a complexly simple language.

Check out here on how to set up ruby in Windows.

How to run Ruby Programs?

In the command prompt type
ruby [ur_program_name].rb

How is ruby different from other Languages?

  • It is freely typed , meaning no need int a; or stuff like that just get to the point e.g:-a=5 is valid in ruby so it is a freely typed language.C,C++,Java is NOT
  • No brackets for declaring methods, classes  , just def and end statement, i will show their use later.It seriously reduces clutter
  • It is interpreted rather than being compiled , it has both advantages and disadvantages.C,C++,Java[an hybrid] are compiled.Lua,Perl,Python[hybrid] are interpreted.
  • Remeber Ruby IS NOT C or Java.It is distinct
  • Everything are objects
  • Automatic garbage disposal like Java . C++ and Delphi do not have Garbage Disposal 
  • More Simple Syntax
That's enough of features , let's start.

Open Notepad++ or notepad.
type:
puts ("I am learning Ruby Hello World!!!!!!!")

Save it as HelloWorld.rb and run it ruby HelloWorld.rb
It will show the following output.
I am learning Ruby Hello World!!!!!!!

Now let's do some calculations
code:
num = 3
num2 = 4
num3=num+num2
print (num3)

This will show the following output.
7

Remember for Java and C programmers!
no int but it is freely assigned.no ; at the end of a statement.

That's all for this tutorial Look out for Tut II

[*]Tutorial II is out go now!
Share on Google Plus

About hacktohell

Love technology.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment