Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Saturday, August 8, 2009

Try Ruby on your browser!

If you are ready to spent a 15 minutes of free time, it's enough to learn ruby. Ruby is Japanese brain and quite easy also. It is famous in its simplicity. You need not install ruby to try it, you can do it in your browser- Not joke!
Just navigate to the official website of ruby.


On the sidebar, you have a wonderful tutorial "Ruby in twenty minutes" to start with. Put a click on "Try ruby on browser" -circled in the above screenshot. Then you will get a command prompt like screen on your browser. Then now ruby is ready to what you want!
If you are beginner, type 'help' on the prompt and hit enter. Then the 'virtual' ruby navigate you through an interactive tutorial which is very useful for beginners. The tutorial takes only about 15minutes.

World's Smallest "Hello World" program

It's quite formal way to start with a "hello world!" program while introducing a new programming language. It is convinient by starting from "hello world" because the program may run properly and is helpful in gaining the confedence. Also it gives a proper output - Prints "hello world!" on the monitor. The programmer becomes happy while seeing this output. Here is a simple "hello world!" program in C.

#include
main()
{
printf("hello world!");
}
//output is
//hello world!


Quite simple?
But I think it is not at all simple. The special characters present in the program really offer some disturbances for the beginner, however a C program is not redundant and it is extreamly powerful.

In Python, I found a much more convenient way.

print "hello world!"


Simple?
It seems good but there is still void to shrink.

Take a look at Ruby,

"hello world"


That's it. I didn't found any void to shrink here. Just put the string you want to print in quotes (" ") and it is pretty easy. But this is not the standard way of printing a string on the monitor, as far as the offcial website of Ruby is concerned. They recommends,

puts ("hello world!)


Then the output will be,

Hello World
=> nil

nil stands for there is nothing to return.